feat: use MdWidget for final reply and notifications — full markdown rendering

This commit is contained in:
ymq 2026-08-10 08:18:37 +08:00
parent b6422d646e
commit 6faecb58bd

View File

@ -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: