diff --git a/routes/chat.py b/routes/chat.py index b97bd58..5a540ed 100644 --- a/routes/chat.py +++ b/routes/chat.py @@ -152,7 +152,8 @@ async def enhanced_generate_stream_response( for tool_call_chunk in msg.tool_call_chunks: if tool_call_chunk["name"]: new_content = f"[{message_tag}] {tool_call_chunk['name']}\n" - new_content += tool_call_chunk['args'] + if tool_call_chunk['args']: + new_content += tool_call_chunk['args'] # 处理文本内容 elif msg.content: @@ -162,7 +163,8 @@ async def enhanced_generate_stream_response( if meta_message_tag != message_tag: message_tag = meta_message_tag new_content = f"[{meta_message_tag}]\n" - new_content += msg.text + if msg.text: + new_content += msg.text # 处理工具响应 elif isinstance(msg, ToolMessage) and tool_response and msg.content: