mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-03 20:44:36 +00:00
Add defensive checks for thought_signature modification
Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com>
This commit is contained in:
@@ -28,8 +28,11 @@ class GeminiChatCompletions(chatcmpl.OpenAIChatCompletions):
|
||||
"""
|
||||
for msg in messages:
|
||||
if 'tool_calls' in msg and msg['tool_calls']:
|
||||
# Ensure we're working with a mutable copy of tool_calls
|
||||
if not isinstance(msg['tool_calls'], list):
|
||||
continue
|
||||
for tool_call in msg['tool_calls']:
|
||||
if 'thought_signature' not in tool_call:
|
||||
if isinstance(tool_call, dict) and 'thought_signature' not in tool_call:
|
||||
tool_call['thought_signature'] = ''
|
||||
return messages
|
||||
|
||||
@@ -168,6 +171,7 @@ class GeminiChatCompletions(chatcmpl.OpenAIChatCompletions):
|
||||
) -> tuple[provider_message.Message, dict]:
|
||||
"""Override _closure to add thought_signature to messages"""
|
||||
# Add thought_signature to tool_calls for Gemini compatibility
|
||||
# Note: modifying in place is safe here as parent _closure will make a copy
|
||||
req_messages = self._add_thought_signature_to_messages(req_messages)
|
||||
|
||||
# Call parent implementation
|
||||
|
||||
Reference in New Issue
Block a user