diff --git a/api/app/services/app_chat_service.py b/api/app/services/app_chat_service.py index b0d90643..3f4bc007 100644 --- a/api/app/services/app_chat_service.py +++ b/api/app/services/app_chat_service.py @@ -187,7 +187,7 @@ class AppChatService: "usage": result.get("usage", {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0}), "audio_url": None } - if files: + if processed_files: human_meta["files"].extend(processed_files) # 保存消息 @@ -395,13 +395,8 @@ class AppChatService: "audio_url": None } - if files: - for f in files: - # url = await MultimodalService(self.db).get_file_url(f) - human_meta["files"].append({ - "type": f.type, - "url": f.url - }) + if processed_files: + human_meta["files"].extend(processed_files) if stream_audio_url: assistant_meta["audio_url"] = stream_audio_url diff --git a/api/app/services/draft_run_service.py b/api/app/services/draft_run_service.py index 10ec25d9..0af33357 100644 --- a/api/app/services/draft_run_service.py +++ b/api/app/services/draft_run_service.py @@ -820,7 +820,6 @@ class AgentRunService: conversation_id=conversation_id, max_history=memory_config.get("max_history", 10) ) - print(history) # 6. 处理多模态文件 processed_files = None diff --git a/api/app/services/multimodal_service.py b/api/app/services/multimodal_service.py index e11a8d2b..e7fb3de3 100644 --- a/api/app/services/multimodal_service.py +++ b/api/app/services/multimodal_service.py @@ -713,7 +713,8 @@ class MultimodalService: # 1. 自动检测文件编码 detect = chardet.detect(file_content) - encoding = detect.get("encoding", "utf-8").lower() + encoding = detect.get("encoding") or "utf-8" + encoding = encoding.lower() # 2. 兼容常见中文编码 compatible_encodings = ["utf-8", "gbk", "gb18030", "gb2312", "ascii", "latin-1"]