feat: stop/cancel intent detection

This commit is contained in:
ymq 2026-08-11 14:49:19 +08:00
parent 6b7487d736
commit 662e1b5c04

View File

@ -34,6 +34,14 @@ def _w_card(title, body, kind="info"):
if action == 'send_message':
prompt = msg
# ── 意图识别:停止类指令 ──
stop_keywords = ['停止', '取消', '停下', '终止', '停', 'stop', 'cancel', 'abort']
if any(kw == prompt.strip().lower() or kw in prompt.strip().lower() for kw in stop_keywords):
async def _stop_stream():
yield json.dumps(_w_md("已停止当前任务。"), ensure_ascii=False) + '\n'
return await stream_response(request, _stop_stream, 'text/plain; charset=utf-8')
uid = await get_user()
if not uid:
uid = 'user-01' # 测试兼容