zhaoqingang
2025-02-13 25bf0a51088fa0d0acdc39c6096cc45d699f63a1
app/api/chat.py
@@ -1,6 +1,5 @@
import json
import re
import uuid
from copy import deepcopy
from fastapi import WebSocket, WebSocketDisconnect, APIRouter, Depends
@@ -231,7 +230,8 @@
                        question,
                        agent_id,
                        AgentType.BASIC,
                        current_user.id
                        current_user.id,
                        {"role": "user", "content": question}
                    )
                except Exception as e:
                    logger.error(e)
@@ -345,7 +345,8 @@
                                question,
                                agent_id,
                                AgentType.DIFY,
                                current_user.id
                                current_user.id,
                                {"role": "user", "content": question}
                            )
                            conversation_id = session.conversation_id
                        except Exception as e:
@@ -806,7 +807,7 @@
                                        result = {"message": f"内部错误: {e2}", "type": "close"}
                                        await websocket.send_json(result)
                                        print(f"Error process message of ragflow: {e2}")
                elif agent.type == "documentIa":
                elif chat_type == "documentIa":
                    token = DfTokenDao(db).get_token_by_id(DOCUMENT_IA_QUESTIONS)
                    # print(token)
                    if not token:
@@ -828,7 +829,8 @@
                                question,
                                agent_id,
                                AgentType.DIFY,
                                current_user.id
                                current_user.id,
                                {"role": "user", "content": question}
                            )
                            conversation_id = session.conversation_id
                        except Exception as e:
@@ -929,7 +931,6 @@
                                result = {"message": f"内部错误: {e2}", "type": "close"}
                                await websocket.send_json(result)
                                print(f"Error process message of ragflow: {e2}")
            # 启动任务处理客户端消息
            tasks = [