fix: all yields use chr(10) for NDJSON newlines
This commit is contained in:
parent
d435c8b5ae
commit
a449f8321c
@ -224,12 +224,12 @@ if action == 'send_message':
|
||||
if act.get('action') == 'tool_call':
|
||||
tool = act.get('tool','')
|
||||
label = _tool_labels.get(tool,tool)
|
||||
yield json.dumps({"type":"widget","widget":_w_progress(f"🔄 {label}")},ensure_ascii=False)+'\n'
|
||||
yield json.dumps({"type":"widget","widget":_w_progress(f"🔄 {label}")},ensure_ascii=False)+chr(10)
|
||||
result = await _exec_tool(sor, tool, act.get('params',{}), ctx, uid, org_id)
|
||||
ok = result.startswith("OK:")
|
||||
yield json.dumps({"type":"widget","widget":_w_card(
|
||||
f"{'✅' if ok else '❌'} {label}", _w_text(result),
|
||||
"success" if ok else "error")},ensure_ascii=False)+'\n'
|
||||
"success" if ok else "error")},ensure_ascii=False)+chr(10)
|
||||
msgs.append({"role":"assistant","content":raw})
|
||||
msgs.append({"role":"user","content":f"工具 {tool} 结果:\n{result}"})
|
||||
continue
|
||||
@ -237,7 +237,7 @@ if action == 'send_message':
|
||||
|
||||
if not agent_reply: agent_reply = "处理超时"
|
||||
await sor.C('pipeline_conversations',{'id':getID(),'role':'agent','content':agent_reply,'msg_type':'text','org_id':org_id,'created_by':'system'})
|
||||
yield json.dumps({"type":"widget","widget":_w_card("🤖 驾驶舱 Agent",_w_text(agent_reply),"reply")},ensure_ascii=False)+'\n'
|
||||
yield json.dumps({"type":"widget","widget":_w_card("🤖 驾驶舱 Agent",_w_text(agent_reply),"reply")},ensure_ascii=False)+chr(10)
|
||||
|
||||
return await stream_response(request, agent_stream, 'application/x-ndjson')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user