From 0ad20a631808fcc255a8739d0ea27bfe044f4ea0 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 22 十一月 2024 17:07:31 +0800 Subject: [PATCH] 请求basic_agent换成requests库,保存消息是不再保存中间结果 --- app/api/chat.py | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/api/chat.py b/app/api/chat.py index b2486ab..076950e 100644 --- a/app/api/chat.py +++ b/app/api/chat.py @@ -261,10 +261,19 @@ f"&file_type={file_type}") excel_url = build_file_url(excel_name, 'excel') image_url = build_file_url(image_name, 'image') - try: - SessionService(db).update_session(chat_id, message={"content": output, "role": "assistant"}) - except Exception as e: - logger.error(f"Unexpected error when update_session: {e}") + if excel_url or data.get("e", ""): + try: + SessionService(db).update_session(chat_id, + message={ + "content": output, + "excel_url": excel_url, + "image_url": image_url, + "sql": data.get("sql", ""), + "code": data.get("code", ""), + "e": data.get("e", ""), + "role": "assistant"}) + except Exception as e: + logger.error(f"Unexpected error when update_session: {e}") # 鍙戦�佺粨鏋滅粰瀹㈡埛绔� data["type"] = "message" data["message"] = output -- Gitblit v1.8.0