fix: _find_project fuzzy match; start_agent use project_id not org_id
This commit is contained in:
parent
abf5e82945
commit
058c84775f
@ -434,11 +434,19 @@ async def _classify_intent(model_info, message, ctx, history_msgs, questions_tex
|
||||
|
||||
|
||||
async def _find_project(sor, name, org_id):
|
||||
"""Find project by name."""
|
||||
"""Find project by name (supports partial match)."""
|
||||
if not name: return None
|
||||
# Try exact match first
|
||||
recs = await sor.sqlExe(
|
||||
"SELECT id, name FROM sd_projects WHERE name=${name}$ AND org_id=${oid}$",
|
||||
{"name": name, "oid": org_id})
|
||||
if recs:
|
||||
return recs[0]
|
||||
# Fuzzy match: name contains keyword
|
||||
# Use f-string for LIKE to avoid aiomysql % escaping issues
|
||||
kw = name.replace("'", "''")
|
||||
sql = f"SELECT id, name FROM sd_projects WHERE name LIKE '%{kw}%' AND org_id='{org_id}' LIMIT 1"
|
||||
recs = await sor.sqlExe(sql, {})
|
||||
return recs[0] if recs else None
|
||||
|
||||
|
||||
@ -868,8 +876,8 @@ if action == 'send_message':
|
||||
agent_reply = "请先指定项目。「创建XXX项目」或「切换到XXX项目」"
|
||||
else:
|
||||
tasks = await sor.sqlExe(
|
||||
"SELECT id, title, state FROM pipeline_tasks WHERE tenant_id=${oid}$ AND state='submitted' LIMIT 5",
|
||||
{"oid": org_id})
|
||||
"SELECT id, title, state FROM pipeline_tasks WHERE tenant_id=${pid}$ AND state='submitted' LIMIT 5",
|
||||
{"pid": pid})
|
||||
if not tasks:
|
||||
agent_reply = f"项目「{ctx['project_name']}」暂无待执行任务。\n\n请先提交开发任务,例如:设计用户表结构"
|
||||
else:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user