fix: 删除硬编码停止关键字匹配(把'为什么任务取消了'误判为停止指令),交LLM意图识别

This commit is contained in:
ymq 2026-08-24 14:51:22 +08:00
parent fbd406b174
commit 7fdbb98117

View File

@ -76,13 +76,9 @@ if action == 'send_message':
if file_ctx: if file_ctx:
prompt = "用户本次上传了以下文件:\n\n" + file_ctx + "\n用户指令:" + prompt prompt = "用户本次上传了以下文件:\n\n" + file_ctx + "\n用户指令:" + prompt
# ── 意图识别:停止类指令 ── # 停止/暂停指令不再用硬编码关键字短路——交给 LLM 意图识别(agent system prompt 已明确:
stop_keywords = ['停止', '取消', '停下', '终止', '停', 'stop', 'cancel', 'abort'] # 用户指令「暂停/停止推进」时调 pause_project)。硬编码子串匹配会把「为什么任务取消了」这类
if any(kw == prompt.strip().lower() or kw in prompt.strip().lower() for kw in stop_keywords): # 分析问题误判为停止指令(2026-08 实测),故删除。
async def _stop_stream():
yield json.dumps({"content": "已停止当前任务。"}, ensure_ascii=False) + '\n'
return await stream_response(request, _stop_stream, 'text/plain; charset=utf-8')
uid = await get_user() uid = await get_user()
if not uid: if not uid:
uid = 'user-01' # 测试兼容 uid = 'user-01' # 测试兼容