| | |
| | | import json |
| | | import re |
| | | import uuid |
| | | from copy import deepcopy |
| | | |
| | | from fastapi import WebSocket, WebSocketDisconnect, APIRouter, Depends |
| | |
| | | question, |
| | | agent_id, |
| | | AgentType.BASIC, |
| | | current_user.id |
| | | current_user.id, |
| | | {"role": "user", "content": question} |
| | | ) |
| | | except Exception as e: |
| | | logger.error(e) |
| | |
| | | question, |
| | | agent_id, |
| | | AgentType.DIFY, |
| | | current_user.id |
| | | current_user.id, |
| | | {"role": "user", "content": question} |
| | | ) |
| | | conversation_id = session.conversation_id |
| | | except Exception as e: |
| | |
| | | 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: |
| | |
| | | question, |
| | | agent_id, |
| | | AgentType.DIFY, |
| | | current_user.id |
| | | current_user.id, |
| | | {"role": "user", "content": question} |
| | | ) |
| | | conversation_id = session.conversation_id |
| | | except Exception as e: |
| | |
| | | result = {"message": f"内部错误: {e2}", "type": "close"} |
| | | await websocket.send_json(result) |
| | | print(f"Error process message of ragflow: {e2}") |
| | | |
| | | |
| | | # 启动任务处理客户端消息 |
| | | tasks = [ |