diff --git a/routes/chat.py b/routes/chat.py index 645c449..3e922b3 100644 --- a/routes/chat.py +++ b/routes/chat.py @@ -176,11 +176,11 @@ async def enhanced_generate_stream_response( ("stop_reason" in msg.response_metadata and msg.response_metadata["stop_reason"] == "tool_use") ): for args in function_call.values(): - new_content = f"[{message_tag}] {args['function_name']}\n{args['arguments']}" + new_content += f"[{message_tag}] {args['function_name']}\n{args['arguments']}\n" message_tag = "TOOL_CALL_FINISH" elif isinstance(msg, ToolMessage) and len(msg.content) > 0: message_tag = "TOOL_RESPONSE" - new_content = f"[{message_tag}] {msg.name}\n{msg.text}" + new_content = f"[{message_tag}] {msg.name}\n{msg.text}\n" # 只有当有新内容时才发送chunk if new_content: