Skip to content

Commit ca5add3

Browse files
authored
Merge pull request #2 from sebslight/claude/fix-gemini-reasoning-output-01HtN54rhTPVWkhe2pRNgUk3
fix(gemini): skip empty text parts in thinking blocks extraction
2 parents 977cc8c + f045daa commit ca5add3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,10 @@ def _extract_thinking_blocks_from_parts(
10871087
thinking_blocks: List[ChatCompletionThinkingBlock] = []
10881088
for part in parts:
10891089
if "thoughtSignature" in part:
1090+
# Skip parts with empty text content to avoid adding '{"text": ""}' to reasoning_content
1091+
text_content = part.get("text", "")
1092+
if not text_content:
1093+
continue
10901094
part_copy = part.copy()
10911095
part_copy.pop("thoughtSignature")
10921096
thinking_blocks.append(

0 commit comments

Comments
 (0)