mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-06 07:48:06 +00:00
fix(gemini): capture thoughtSignature from sibling thought parts
Gemini may place thoughtSignature on a separate thought part (thought: true) rather than the functionCall part. _transform_parts only checked the functionCall part for thoughtSignature, so the signature was lost when it was on a sibling thought part. Now we collect all thoughtSignature values from all parts before iterating, and fall back to the first available signature when a functionCall part has none of its own. Fixes #25322 (Failure 1) Signed-off-by: bahtya <bahtyar153@qq.com>
This commit is contained in:
parent
c014bfa683
commit
fa3159b6e8
1 changed files with 12 additions and 2 deletions
|
|
@ -1585,6 +1585,13 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
]:
|
||||
function: Optional[ChatCompletionToolCallFunctionChunk] = None
|
||||
_tools: List[ChatCompletionToolCallChunk] = []
|
||||
# Collect all thoughtSignature values from any part (Gemini may place
|
||||
# the signature on a separate thought part, not the functionCall part)
|
||||
_all_signatures = [
|
||||
p.get("thoughtSignature")
|
||||
for p in parts
|
||||
if p.get("thoughtSignature")
|
||||
]
|
||||
for part in parts:
|
||||
if "functionCall" in part:
|
||||
_function_chunk: ChatCompletionToolCallFunctionChunk = {
|
||||
|
|
@ -1593,8 +1600,11 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
part["functionCall"]["args"], ensure_ascii=False
|
||||
),
|
||||
}
|
||||
# Extract thought signature if present
|
||||
thought_signature = part.get("thoughtSignature")
|
||||
# Extract thought signature: prefer this part's own, fallback to
|
||||
# a signature from a sibling thought part
|
||||
thought_signature = part.get("thoughtSignature") or (
|
||||
_all_signatures[0] if _all_signatures else None
|
||||
)
|
||||
|
||||
if is_function_call is True:
|
||||
function_dict: Dict[str, Any] = dict(_function_chunk)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue