mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-12 18:01:30 +08:00
fix: gemini tool call bug
This commit is contained in:
@@ -521,6 +521,7 @@ class AgentStreamExecutor:
|
||||
# Streaming response
|
||||
full_content = ""
|
||||
tool_calls_buffer = {} # {index: {id, name, arguments}}
|
||||
gemini_raw_parts = None # Preserve Gemini thoughtSignature for round-trip
|
||||
stop_reason = None # Track why the stream stopped
|
||||
|
||||
try:
|
||||
@@ -612,6 +613,10 @@ class AgentStreamExecutor:
|
||||
if "arguments" in func:
|
||||
tool_calls_buffer[index]["arguments"] += func["arguments"]
|
||||
|
||||
# Preserve _gemini_raw_parts for Gemini thoughtSignature round-trip
|
||||
if "_gemini_raw_parts" in delta:
|
||||
gemini_raw_parts = delta["_gemini_raw_parts"]
|
||||
|
||||
except Exception as e:
|
||||
error_str = str(e)
|
||||
error_str_lower = error_str.lower()
|
||||
@@ -793,6 +798,9 @@ class AgentStreamExecutor:
|
||||
"input": tc.get("arguments", {})
|
||||
})
|
||||
|
||||
if gemini_raw_parts:
|
||||
assistant_msg["_gemini_raw_parts"] = gemini_raw_parts
|
||||
|
||||
# Only append if content is not empty
|
||||
if assistant_msg["content"]:
|
||||
self.messages.append(assistant_msg)
|
||||
|
||||
@@ -294,6 +294,9 @@ class OpenAICompatibleBot:
|
||||
if tool_calls:
|
||||
openai_msg["tool_calls"] = tool_calls
|
||||
|
||||
if msg.get("_gemini_raw_parts"):
|
||||
openai_msg["_gemini_raw_parts"] = msg["_gemini_raw_parts"]
|
||||
|
||||
openai_messages.append(openai_msg)
|
||||
else:
|
||||
# Other list content, keep as is
|
||||
|
||||
Reference in New Issue
Block a user