From 6be3990bfe27b798b19cc257af468f2a3c41e8e5 Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期一, 25 十一月 2024 12:02:50 +0800 Subject: [PATCH] dify 对话测试 --- app/api/chat.py | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/api/chat.py b/app/api/chat.py index 483a69a..2a511e1 100644 --- a/app/api/chat.py +++ b/app/api/chat.py @@ -315,6 +315,8 @@ logger.error(e) complete_response = "" async for rag_response in dify_service.chat(token, current_user.id, question, upload_file_id, conversation_id): + logger.error("=============================================") + logger.error(rag_response) try: if rag_response[:5] == "data:": # 濡傛灉鏄紝鍒欐埅鍙栨帀鍓�5涓瓧绗︼紝骞跺幓闄ら灏剧┖鐧界 @@ -327,6 +329,8 @@ data = json.loads(complete_response) # data = json_data.get("data") if "answer" not in data or not isinstance(data["answer"], dict): # 淇℃伅杩囨护 + logger.error("闈炴硶鏁版嵁--------------------") + logger.error(data) continue else: # 姝e父杈撳嚭 answer = data.get("answer", "") @@ -336,6 +340,7 @@ SessionService(db).update_session(chat_id, message={"role": "assistant", "content": data, "conversation_id": data.get("conversation_id")}) except Exception as e: + logger.error("淇濆瓨dify鐨勪細璇濆紓甯革紒") logger.error(e) await websocket.send_json(result) complete_response = "" @@ -346,12 +351,7 @@ result = {"message": f"鍐呴儴閿欒锛� {e2}", "type": "close"} await websocket.send_json(result) print(f"Error process message of ragflow: {e2}") - try: - dialog_chat_history = await ragflow_service.get_session_history(token, chat_id, 1) - await update_session_history(db, dialog_chat_history, current_user.id) - except Exception as e: - logger.error(e) - logger.error("-----------------淇濆瓨ragflow鐨勫巻鍙蹭細璇濆紓甯�-----------------") + # 鍚姩浠诲姟澶勭悊瀹㈡埛绔秷鎭� tasks = [ -- Gitblit v1.8.0