fix(gemini): filter out thought=true image parts in LiteLLM vertex parser

Gemini image-preview models may return intermediate images during reasoning
with `thought=true`. LiteLLM was including these images in final responses,
resulting in multiple images returned.

This patch filters out parts where `thought=true` during image extraction.
This commit is contained in:
darkal 2026-03-31 23:30:19 +08:00 • committed by GitHub
parent 9942d59631
commit 1bf5a88408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1431,6 +1431,8 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
"""Extract image response from parts if present"""
images: List[ImageURLListItem] = []
for part in parts:
if isinstance(part, dict) and part.get("thought") is True:
continue
if "inlineData" in part:
inline_data = part.get("inlineData", {})
mime_type = inline_data.get("mimeType", "")