fix: use proper DSPY context for diagnose
This commit is contained in:
parent
f55317fbe8
commit
a14669790f
@ -1,17 +1,61 @@
|
|||||||
# test_diagnose.dspy - 直接诊断人事项目
|
# test_diagnose.dspy - 直接诊断人事项目
|
||||||
|
|
||||||
from pipeline_service.agent_loop_v2 import AgentExecutor
|
|
||||||
from pipeline_core.agent_config import SDLC_DEFAULT_CONFIG
|
|
||||||
|
|
||||||
uid = 'user-01'
|
uid = 'user-01'
|
||||||
pid = 'T_2hWHTqqwgf8igNMHLQk' # 人事项目
|
pid = 'T_2hWHTqqwgf8igNMHLQk'
|
||||||
|
|
||||||
executor = AgentExecutor(config=SDLC_DEFAULT_CONFIG, project_id=pid, user_id=uid)
|
dbname = get_module_dbname('pipeline-sdlc')
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
# 任务统计
|
||||||
|
submitted = await sor.sqlExe(
|
||||||
|
"SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='submitted'",
|
||||||
|
{"pid": pid})
|
||||||
|
running = await sor.sqlExe(
|
||||||
|
"SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='running'",
|
||||||
|
{"pid": pid})
|
||||||
|
failed = await sor.sqlExe(
|
||||||
|
"SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='failed'",
|
||||||
|
{"pid": pid})
|
||||||
|
review = await sor.sqlExe(
|
||||||
|
"SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='review'",
|
||||||
|
{"pid": pid})
|
||||||
|
approved = await sor.sqlExe(
|
||||||
|
"SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='approved'",
|
||||||
|
{"pid": pid})
|
||||||
|
completed = await sor.sqlExe(
|
||||||
|
"SELECT COUNT(*) as c FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='completed'",
|
||||||
|
{"pid": pid})
|
||||||
|
|
||||||
# 手动调用 diagnose 和 list_tasks
|
# 任务列表
|
||||||
async with DBPools().sqlorContext('pipeline') as sor:
|
tasks = await sor.sqlExe(
|
||||||
diag = await executor._t_diagnose_project(sor, {}, pid)
|
"SELECT id, title, role, state FROM pipeline_tasks WHERE tenant_id=${pid}$ ORDER BY created_at DESC LIMIT 20",
|
||||||
tasks = await executor._t_list_tasks(sor, {}, pid)
|
{"pid": pid})
|
||||||
|
task_list = [{"id": getattr(t,'id','')[:8], "title": getattr(t,'title',''),
|
||||||
|
"role": getattr(t,'role',''), "state": getattr(t,'state','')}
|
||||||
|
for t in (tasks or [])]
|
||||||
|
|
||||||
result = {"diagnose": diag, "tasks": tasks}
|
# 交付件
|
||||||
return json.dumps(result, ensure_ascii=False)
|
delivs = await sor.sqlExe(
|
||||||
|
"SELECT COUNT(*) as c FROM pipeline_deliverables WHERE project_id=${pid}$",
|
||||||
|
{"pid": pid})
|
||||||
|
|
||||||
|
# 项目信息
|
||||||
|
proj = await sor.sqlExe(
|
||||||
|
"SELECT name, description, status FROM sd_projects WHERE id=${pid}$",
|
||||||
|
{"pid": pid})
|
||||||
|
pname = getattr(proj[0], 'name', '') if proj else ''
|
||||||
|
|
||||||
|
result = {
|
||||||
|
"project": pname,
|
||||||
|
"status": {
|
||||||
|
"submitted": getattr(submitted[0], 'c', 0) if submitted else 0,
|
||||||
|
"running": getattr(running[0], 'c', 0) if running else 0,
|
||||||
|
"failed": getattr(failed[0], 'c', 0) if failed else 0,
|
||||||
|
"review": getattr(review[0], 'c', 0) if review else 0,
|
||||||
|
"approved": getattr(approved[0], 'c', 0) if approved else 0,
|
||||||
|
"completed": getattr(completed[0], 'c', 0) if completed else 0,
|
||||||
|
"deliverables": getattr(delivs[0], 'c', 0) if delivs else 0,
|
||||||
|
},
|
||||||
|
"tasks": task_list,
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False, default=str)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user