cockpit_chat: use _w_progress/_w_card/_w_text widget descriptors in yield stream
This commit is contained in:
parent
61a3ae43b5
commit
426998b6c6
@ -234,12 +234,12 @@ if action == 'send_message':
|
|||||||
if act.get('action') == 'tool_call':
|
if act.get('action') == 'tool_call':
|
||||||
tool = act.get('tool','')
|
tool = act.get('tool','')
|
||||||
label = _tool_labels.get(tool,tool)
|
label = _tool_labels.get(tool,tool)
|
||||||
d = json.dumps({"content": f"🔄 {label}..."}, ensure_ascii=False)+'\n'
|
d = json.dumps(_w_progress(f"🔄 {label}..."), ensure_ascii=False)+'\n'
|
||||||
debug(f"YIELD progress: {d[:60]}")
|
debug(f"YIELD progress: {d[:60]}")
|
||||||
yield d
|
yield d
|
||||||
result = await _exec_tool(sor, tool, act.get('params',{}), ctx, uid, org_id)
|
result = await _exec_tool(sor, tool, act.get('params',{}), ctx, uid, org_id)
|
||||||
ok = result.startswith("OK:")
|
ok = result.startswith("OK:")
|
||||||
d = json.dumps({"content": f"{'✅' if ok else '❌'} {label}: {result}"}, ensure_ascii=False)+'\n'
|
d = json.dumps(_w_card(label, _w_text(result), "success" if ok else "error"), ensure_ascii=False)+'\n'
|
||||||
debug(f"YIELD result: {d[:60]}")
|
debug(f"YIELD result: {d[:60]}")
|
||||||
yield d
|
yield d
|
||||||
msgs.append({"role":"assistant","content":raw})
|
msgs.append({"role":"assistant","content":raw})
|
||||||
@ -248,7 +248,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({"content": agent_reply}, ensure_ascii=False)+'\n'
|
d = json.dumps(_w_text(agent_reply), ensure_ascii=False)+'\n'
|
||||||
debug(f"YIELD final: {d[:60]}")
|
debug(f"YIELD final: {d[:60]}")
|
||||||
yield d
|
yield d
|
||||||
await sor.C('pipeline_conversations',{'id':getID(),'role':'agent','content':agent_reply,'msg_type':'text','org_id':org_id,'created_by':'system'})
|
await sor.C('pipeline_conversations',{'id':getID(),'role':'agent','content':agent_reply,'msg_type':'text','org_id':org_id,'created_by':'system'})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user