From 3fc9f4f33cf90610c71a1de7b00db0f82b988e98 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 16 十月 2024 23:22:53 +0800 Subject: [PATCH] 文档上传&获取报告生成变量&报告生成接口 --- app/api/chat.py | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/api/chat.py b/app/api/chat.py index 828b7e8..458581a 100644 --- a/app/api/chat.py +++ b/app/api/chat.py @@ -29,11 +29,13 @@ agent = db.query(AgentModel).filter(AgentModel.id == agent_id).first() if not agent: ret = {"message": "Agent not found", "type": "close"} - return websocket.send_json(ret) + await websocket.send_json(ret) + return agent_type = agent.agent_type if chat_id == "" or chat_id == "0": ret = {"message": "Chat ID not found", "type": "close"} - return websocket.send_json(ret) + await websocket.send_json(ret) + return if agent_type == AgentType.RAGFLOW: ragflow_service = RagflowService(settings.ragflow_base_url) @@ -50,7 +52,6 @@ if len(chat_history) == 0: result = {"message": "鍐呴儴閿欒锛氬垱寤轰細璇濆け璐�", "type": "close"} await websocket.send_json(result) - continue async for rag_response in ragflow_service.chat(token, chat_id, chat_history): try: print(f"Received from ragflow: {rag_response}") @@ -143,5 +144,5 @@ print(f"Client {chat_id} disconnected") else: ret = {"message": "Agent not found", "type": "close"} - return websocket.send_json(ret) + await websocket.send_json(ret) -- Gitblit v1.8.0