From 6faecb58bd2fcf12cdd00b8a2986a33649e73ccd Mon Sep 17 00:00:00 2001 From: ymq Date: Mon, 10 Aug 2026 08:18:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20use=20MdWidget=20for=20final=20reply=20?= =?UTF-8?q?and=20notifications=20=E2=80=94=20full=20markdown=20rendering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/cockpit_chat.dspy | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 4054689..e8c6365 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -167,6 +167,7 @@ def _parse(raw): return {"action":"reply","message":clean or raw} def _w_text(t): return {"widgettype":"Text","options":{"text":t,"css":"agent-text","halign":"left"}} +def _w_md(t): return {"widgettype":"MdWidget","options":{"mdtext":t,"css":"resp-content","width":"100%"}} def _w_card(title, body, kind="success"): colors = {"success":"#10b981","error":"#ef4444","reply":"#6366f1","progress":"#f59e0b"} c = colors.get(kind,"#6b7280") @@ -523,7 +524,7 @@ if action == 'send_message': agent_reply = '' # Push active notifications before LLM processing if pending_qs: - d = json.dumps(_w_text(f"📬 待回答问题({len(pending_qs)}个):\n" + '\n'.join(pending_qs)), ensure_ascii=False)+'\n' + d = json.dumps(_w_md(f"📬 **待回答问题({len(pending_qs)}个)**:\n" + '\n'.join(pending_qs)), ensure_ascii=False)+'\n' yield d for turn in range(10): raw = await _call_llm(model, msgs, 0.4) @@ -557,7 +558,7 @@ if action == 'send_message': agent_reply = raw; break if not agent_reply: agent_reply = "处理超时" - d = json.dumps(_w_text(agent_reply), ensure_ascii=False)+'\n' + d = json.dumps(_w_md(agent_reply), ensure_ascii=False)+'\n' debug(f"YIELD final: {d[:60]}") yield d if uid: