From 237bb8514e265c8ac5e02ddb00e1f3d88375e7c2 Mon Sep 17 00:00:00 2001 From: Vikey Chen Date: Fri, 8 Mar 2024 18:46:31 +0800 Subject: [PATCH] replace message content type list to string when file_objs is empty .. (#2745) --- api/core/memory/token_buffer_memory.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/api/core/memory/token_buffer_memory.py b/api/core/memory/token_buffer_memory.py index f1f8ab3a3b..4d44ac3818 100644 --- a/api/core/memory/token_buffer_memory.py +++ b/api/core/memory/token_buffer_memory.py @@ -47,11 +47,14 @@ class TokenBufferMemory: files, message.app_model_config ) - prompt_message_contents = [TextPromptMessageContent(data=message.query)] - for file_obj in file_objs: - prompt_message_contents.append(file_obj.prompt_message_content) + if not file_objs: + prompt_messages.append(UserPromptMessage(content=message.query)) + else: + prompt_message_contents = [TextPromptMessageContent(data=message.query)] + for file_obj in file_objs: + prompt_message_contents.append(file_obj.prompt_message_content) - prompt_messages.append(UserPromptMessage(content=prompt_message_contents)) + prompt_messages.append(UserPromptMessage(content=prompt_message_contents)) else: prompt_messages.append(UserPromptMessage(content=message.query))