feat: use MdWidget for final reply and notifications — full markdown rendering
This commit is contained in:
parent
b6422d646e
commit
6faecb58bd
@ -167,6 +167,7 @@ def _parse(raw):
|
|||||||
return {"action":"reply","message":clean or 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_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"):
|
def _w_card(title, body, kind="success"):
|
||||||
colors = {"success":"#10b981","error":"#ef4444","reply":"#6366f1","progress":"#f59e0b"}
|
colors = {"success":"#10b981","error":"#ef4444","reply":"#6366f1","progress":"#f59e0b"}
|
||||||
c = colors.get(kind,"#6b7280")
|
c = colors.get(kind,"#6b7280")
|
||||||
@ -523,7 +524,7 @@ if action == 'send_message':
|
|||||||
agent_reply = ''
|
agent_reply = ''
|
||||||
# Push active notifications before LLM processing
|
# Push active notifications before LLM processing
|
||||||
if pending_qs:
|
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
|
yield d
|
||||||
for turn in range(10):
|
for turn in range(10):
|
||||||
raw = await _call_llm(model, msgs, 0.4)
|
raw = await _call_llm(model, msgs, 0.4)
|
||||||
@ -557,7 +558,7 @@ if action == 'send_message':
|
|||||||
agent_reply = raw; break
|
agent_reply = raw; break
|
||||||
|
|
||||||
if not agent_reply: agent_reply = "处理超时"
|
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]}")
|
debug(f"YIELD final: {d[:60]}")
|
||||||
yield d
|
yield d
|
||||||
if uid:
|
if uid:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user