From 662e1b5c04a40ad2eb66e90f9395d3895854bbea Mon Sep 17 00:00:00 2001 From: ymq Date: Tue, 11 Aug 2026 14:49:19 +0800 Subject: [PATCH] feat: stop/cancel intent detection --- wwwroot/api/cockpit_chat_v2.dspy | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wwwroot/api/cockpit_chat_v2.dspy b/wwwroot/api/cockpit_chat_v2.dspy index fb11f41..2a95731 100644 --- a/wwwroot/api/cockpit_chat_v2.dspy +++ b/wwwroot/api/cockpit_chat_v2.dspy @@ -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' # 测试兼容