From 69c77e307999f437f6e5a1b28f34eba42e3576d6 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期二, 19 十一月 2024 21:27:37 +0800
Subject: [PATCH] 审计结果增加文件下载地址
---
app/api/chat.py | 19 ++++++++++++-------
1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/app/api/chat.py b/app/api/chat.py
index b5bfd6a..a42c819 100644
--- a/app/api/chat.py
+++ b/app/api/chat.py
@@ -208,7 +208,6 @@
continue
service = BasicService(base_url=settings.basic_base_url)
- complete_response = ""
async for result in service.excel_talk(question, chat_id):
try:
if result[:5] == "data:":
@@ -217,13 +216,19 @@
else:
# 鍚﹀垯锛屼繚鎸佸師鏍�
text = result
- complete_response += text
try:
- json_data = json.loads(complete_response)
- output = json_data.get("output", "")
- result = {"message": output, "type": "message"}
- await websocket.send_json(result | json_data)
- complete_response = ""
+ data = json.loads(text)
+ output = data.get("output", "")
+ excel_name = data.get("excel_name", "")
+ image_name = data.get("excel_name", "")
+ excel_url = None
+ image_url = None
+ if excel_name:
+ excel_url = f"/api/files/download/?agent_id=basic_excel_talk&file_id={excel_name}&file_type=excel"
+ if image_name:
+ image_url = f"/api/files/download/?agent_id=basic_excel_talk&file_id={image_name}&file_type=image"
+ result = {"message": output, "type": "message", "excel_url": excel_url, "image_url": image_url}
+ await websocket.send_json(result | data)
except json.JSONDecodeError as e:
print(f"Error decoding JSON: {e}")
print(f"Response text: {text}")
--
Gitblit v1.8.0