From c3f8dbd4bc6e7f2e7c93151531ce8caf32eb0f6d Mon Sep 17 00:00:00 2001 From: Eternity <1533512157@qq.com> Date: Thu, 19 Mar 2026 19:21:39 +0800 Subject: [PATCH] fix(conversation): handle None meta_data in msg to prevent exceptions --- api/app/services/app_chat_service.py | 4 ++-- api/app/services/conversation_service.py | 2 +- api/app/services/shared_chat_service.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/app/services/app_chat_service.py b/api/app/services/app_chat_service.py index 3f4bc007..d81ba7b7 100644 --- a/api/app/services/app_chat_service.py +++ b/api/app/services/app_chat_service.py @@ -124,7 +124,7 @@ class AppChatService: limit=10 ) history = [ - {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + msg.meta_data.get("files", [])} + {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + (msg.meta_data.get("files", []) if msg.meta_data else [])} for msg in messages ] @@ -317,7 +317,7 @@ class AppChatService: limit=memory_config.get("max_history", 10) ) history = [ - {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + msg.meta_data.get("files", [])} + {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + (msg.meta_data.get("files", []) if msg.meta_data else [])} for msg in messages ] diff --git a/api/app/services/conversation_service.py b/api/app/services/conversation_service.py index 2ca50257..30c3feba 100644 --- a/api/app/services/conversation_service.py +++ b/api/app/services/conversation_service.py @@ -293,7 +293,7 @@ class ConversationService: history = [ { "role": msg.role, - "content": [{"type": "text", "text": msg.content}] + msg.meta_data.get("files", []) + "content": [{"type": "text", "text": msg.content}] + (msg.meta_data.get("files", []) if msg.meta_data else []) } for msg in messages ] diff --git a/api/app/services/shared_chat_service.py b/api/app/services/shared_chat_service.py index a8a31997..5e18ee42 100644 --- a/api/app/services/shared_chat_service.py +++ b/api/app/services/shared_chat_service.py @@ -264,7 +264,7 @@ class SharedChatService: limit=memory_config.get("max_history", 10) ) history = [ - {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + msg.meta_data.get("files", [])} + {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + (msg.meta_data.get("files", []) if msg.meta_data else [])} for msg in messages ] @@ -472,7 +472,7 @@ class SharedChatService: limit=memory_config.get("max_history", 10) ) history = [ - {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + msg.meta_data.get("files", [])} + {"role": msg.role, "content": [{"type": "text", "text": msg.content}] + (msg.meta_data.get("files", []) if msg.meta_data else [])} for msg in messages ]