mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
Address Gemini thought signature review feedback
This commit is contained in:
parent
3f2e6dca6f
commit
3b45b170fe
3 changed files with 50 additions and 4 deletions
|
|
@ -994,10 +994,6 @@ def _gemini_convert_messages_with_history( # noqa: PLR0915
|
|||
if (
|
||||
isinstance(existing_part, dict)
|
||||
and existing_part.get("thoughtSignature")
|
||||
and (
|
||||
existing_part.get("functionCall") is not None
|
||||
or existing_part.get("function_call") is not None
|
||||
)
|
||||
):
|
||||
turn_thought_signature = existing_part.get(
|
||||
"thoughtSignature"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class PartType(TypedDict, total=False):
|
|||
inline_data: BlobType
|
||||
file_data: FileDataType
|
||||
function_call: FunctionCall
|
||||
functionCall: FunctionCall
|
||||
function_response: FunctionResponse
|
||||
thought: bool
|
||||
thoughtSignature: str
|
||||
|
|
|
|||
|
|
@ -569,6 +569,55 @@ def test_parallel_tool_calls_copy_thought_signature_from_thinking_block():
|
|||
assert all(p.get("thoughtSignature") == "sig-turn-123" for p in function_parts)
|
||||
|
||||
|
||||
def test_parallel_tool_calls_copy_thought_signature_from_text_thinking_block():
|
||||
"""Text-fallback thinking blocks still carry the turn signature."""
|
||||
messages = [
|
||||
{
|
||||
"role": "assistant",
|
||||
"content": None,
|
||||
"thinking_blocks": [
|
||||
{
|
||||
"type": "thinking",
|
||||
"thinking": "I need to call both tools.",
|
||||
"signature": "sig-text-thinking",
|
||||
}
|
||||
],
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "call_1",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_current_temperature",
|
||||
"arguments": '{"location": "Paris"}',
|
||||
},
|
||||
"index": 0,
|
||||
},
|
||||
{
|
||||
"id": "call_2",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_current_temperature",
|
||||
"arguments": '{"location": "London"}',
|
||||
},
|
||||
"index": 1,
|
||||
},
|
||||
],
|
||||
}
|
||||
]
|
||||
|
||||
contents = _gemini_convert_messages_with_history(messages, model="gemini-2.5-flash")
|
||||
|
||||
function_parts = [
|
||||
p
|
||||
for p in contents[0]["parts"]
|
||||
if p.get("functionCall") is not None or p.get("function_call") is not None
|
||||
]
|
||||
assert len(function_parts) == 2
|
||||
assert all(
|
||||
p.get("thoughtSignature") == "sig-text-thinking" for p in function_parts
|
||||
)
|
||||
|
||||
|
||||
def test_thought_signature_with_function_call_mode():
|
||||
"""Test thought signature extraction in function_call mode (is_function_call=True)"""
|
||||
from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue