From b1b98caad789614ea8fbdc750a9403fc4c425553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Sat, 4 Apr 2026 23:31:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E8=AE=BF=E9=97=AE=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E5=85=BC=E5=AE=B9=20dict=20=E5=92=8C?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E4=B8=A4=E7=A7=8D=E7=B1=BB=E5=9E=8B=E3=80=82?= =?UTF-8?q?=E8=BF=99=E6=A0=B7=E5=8D=B3=E4=BD=BF=E6=9F=90=E4=B8=AA=20chunk?= =?UTF-8?q?=20=E7=BC=BA=E5=B0=91=20name=20=E5=AD=97=E6=AE=B5=E4=B9=9F?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E5=B4=A9=E6=BA=83=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/chat.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/routes/chat.py b/routes/chat.py index a6e803b..40cf8ee 100644 --- a/routes/chat.py +++ b/routes/chat.py @@ -102,10 +102,12 @@ async def enhanced_generate_stream_response( message_tag = "TOOL_CALL" if config.tool_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" - if tool_call_chunk['args']: - new_content += tool_call_chunk['args'] + chunk_name = tool_call_chunk.get("name") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "name", None) + chunk_args = tool_call_chunk.get("args") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "args", None) + if chunk_name: + new_content = f"[{message_tag}] {chunk_name}\n" + if chunk_args: + new_content += chunk_args # 处理文本内容 elif msg.content: preamble_completed.set()