|
@@ -11,7 +11,7 @@ from Log import logger
|
|
|
from app.api import get_current_user_websocket
|
|
from app.api import get_current_user_websocket
|
|
|
from app.config.config import settings
|
|
from app.config.config import settings
|
|
|
from app.config.const import IMAGE_TO_TEXT, DOCUMENT_TO_REPORT, DOCUMENT_TO_CLEANING, DOCUMENT_IA_QUESTIONS, \
|
|
from app.config.const import IMAGE_TO_TEXT, DOCUMENT_TO_REPORT, DOCUMENT_TO_CLEANING, DOCUMENT_IA_QUESTIONS, \
|
|
|
- DOCUMENT_TO_REPORT_TITLE, DOCUMENT_TO_TITLE, DOCUMENT_TO_PAPER
|
|
|
|
|
|
|
+ DOCUMENT_TO_REPORT_TITLE, DOCUMENT_TO_TITLE, DOCUMENT_TO_PAPER, DOCUMENT_IA_QUESTIONS_DS
|
|
|
from app.models import MenuCapacityModel
|
|
from app.models import MenuCapacityModel
|
|
|
from app.models.agent_model import AgentModel, AgentType
|
|
from app.models.agent_model import AgentModel, AgentType
|
|
|
from app.models.base_model import get_db
|
|
from app.models.base_model import get_db
|
|
@@ -807,8 +807,12 @@ async def handle_client(websocket: WebSocket,
|
|
|
result = {"message": f"内部错误: {e2}", "type": "close"}
|
|
result = {"message": f"内部错误: {e2}", "type": "close"}
|
|
|
await websocket.send_json(result)
|
|
await websocket.send_json(result)
|
|
|
print(f"Error process message of ragflow: {e2}")
|
|
print(f"Error process message of ragflow: {e2}")
|
|
|
- elif chat_type == "documentIa":
|
|
|
|
|
- token = DfTokenDao(db).get_token_by_id(DOCUMENT_IA_QUESTIONS)
|
|
|
|
|
|
|
+ elif chat_type == "documentIa" or chat_type == "documentIaDs":
|
|
|
|
|
+ token_dict = {
|
|
|
|
|
+ "documentIa": DOCUMENT_IA_QUESTIONS,
|
|
|
|
|
+ "documentIaDs": DOCUMENT_IA_QUESTIONS_DS,
|
|
|
|
|
+ }
|
|
|
|
|
+ token = DfTokenDao(db).get_token_by_id(token_dict[chat_type])
|
|
|
# print(token)
|
|
# print(token)
|
|
|
if not token:
|
|
if not token:
|
|
|
await websocket.send_json({"message": "Invalid token", "type": "error"})
|
|
await websocket.send_json({"message": "Invalid token", "type": "error"})
|
|
@@ -874,11 +878,13 @@ async def handle_client(websocket: WebSocket,
|
|
|
logger.error(data)
|
|
logger.error(data)
|
|
|
continue
|
|
continue
|
|
|
elif isinstance(answer, dict):
|
|
elif isinstance(answer, dict):
|
|
|
|
|
+ if answer.get("status") == "failed":
|
|
|
|
|
+ message = answer.get("error", "")
|
|
|
|
|
+ else:
|
|
|
|
|
+ message = answer.get("title", "")
|
|
|
|
|
|
|
|
- message = answer.get("title", "")
|
|
|
|
|
-
|
|
|
|
|
- result = {"message": message, "type": "system"}
|
|
|
|
|
- continue
|
|
|
|
|
|
|
+ result = {"message": message, "type": "system"}
|
|
|
|
|
+ # continue
|
|
|
elif data.get("event") == "message": # "event": "message_end"
|
|
elif data.get("event") == "message": # "event": "message_end"
|
|
|
# 正常输出
|
|
# 正常输出
|
|
|
answer = data.get("answer", "")
|
|
answer = data.get("answer", "")
|