From c0d11dac469251c71b036c757c788615285c9683 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 15 十一月 2024 10:57:10 +0800
Subject: [PATCH] 毕昇对话历史只返回了一条修正,按时间正序排列吧,json乱码修正
---
app/api/report.py | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/app/api/report.py b/app/api/report.py
index 232c4b0..b2bac8a 100644
--- a/app/api/report.py
+++ b/app/api/report.py
@@ -65,16 +65,19 @@
files = data.get("files", [])
steps = data.get("intermediate_steps", "")
msg = data.get("message", "")
+ category = data.get("category", "")
- if len(files) != 0 or (steps and last_message == "step") or msg or data["type"] == "close":
+ if len(files) != 0 or (msg and category != "answer") or data["type"] == "close":
if data["type"] == "close":
t = "close"
else:
t = "stream"
process_files(files, agent_id)
- result = {"step_message": steps, "message": msg, "type": t, "files": files}
+ result = {"message": msg, "type": t, "files": files}
await websocket.send_json(result)
- print(f"Forwarded to client, {chat_id}: {result}")
+ elif steps and last_message == "step":
+ result = {"step_message": steps, "type": "stream", "files": files}
+ await websocket.send_json(result)
last_message = "message" if msg else "step"
@@ -90,7 +93,8 @@
task.cancel()
try:
await task
- except asyncio.CancelledError:
+ except asyncio.CancelledError as e:
+ print(f"asyncio CancelledError: {e}")
pass
except WebSocketDisconnect as e:
--
Gitblit v1.8.0