zhaoqingang
2025-02-13 39bade10a3d7bc89fa5f37c9a0130ac7d5051719
app/api/chat.py
@@ -11,7 +11,7 @@
from app.api import get_current_user_websocket
from app.config.config import settings
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.agent_model import AgentModel, AgentType
from app.models.base_model import get_db
@@ -807,8 +807,12 @@
                                        result = {"message": f"内部错误: {e2}", "type": "close"}
                                        await websocket.send_json(result)
                                        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)
                    if not token:
                        await websocket.send_json({"message": "Invalid token", "type": "error"})
@@ -874,11 +878,13 @@
                                                logger.error(data)
                                                continue
                                            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"
                                        # 正常输出
                                        answer = data.get("answer", "")