zhaoqingang
2025-03-18 282a631b9ceee9a634ee1d93751a5254ed37ccef
app/api/chat.py
@@ -71,11 +71,12 @@
                    chat_history = message.get('chatHistory', [])
                    message["role"] = "user"
                    if len(chat_history) == 0:
                        print("----------------------", token)
                        chat_history = await ragflow_service.get_session_history(token, chat_id)
                        if len(chat_history) == 0:
                            chat_history = await ragflow_service.set_session(token, agent_id,
                                                                             message, chat_id, True)
                            # print("chat_history------------------------", chat_history)
                            print("chat_history------------------------", chat_history)
                            if len(chat_history) == 0:
                                result = {"message": "内部错误:创建会话失败", "type": "close"}
                                await websocket.send_json(result)
@@ -325,7 +326,7 @@
        # token = get_dify_token(db, current_user.id)
        try:
            async def forward_to_dify():
                if agent.type == "imageTalk":
                if chat_type == "imageTalk":
                    token = DfTokenDao(db).get_token_by_id(IMAGE_TO_TEXT)
                    if not token:
                        await websocket.send_json({"message": "Invalid token", "type": "error"})
@@ -431,7 +432,7 @@
                                result = {"message": f"内部错误: {e2}", "type": "close"}
                                await websocket.send_json(result)
                                print(f"Error process message of ragflow: {e2}")
                elif agent.type == "reportWorkflow":
                elif chat_type == "reportWorkflow":
                    while True:
                        receive_message = await websocket.receive_json()