mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
fix: guard against None text in Gemini image generation response parts
When Gemini returns image generation responses, the parts array can contain a 'text' key whose value is null (JSON null). The code checked for key existence with 'if "text" in part' but did not guard against a null value, causing AttributeError: 'NoneType' object has no attribute 'startswith'. Add an explicit 'if text_content is None: continue' guard in both get_assistant_content_message() and _extract_audio_response_from_parts() immediately after reading part['text']. Fixes BerriAI/litellm#24385
This commit is contained in:
parent
25ee2fb3f9
commit
bfb7878cec
1 changed files with 4 additions and 0 deletions
|
|
@ -1281,6 +1281,8 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
_content_str = ""
|
||||
if "text" in part:
|
||||
text_content = part["text"]
|
||||
if text_content is None:
|
||||
continue
|
||||
# Check if text content is audio data URI - if so, exclude from text content
|
||||
if text_content.startswith("data:audio") and ";base64," in text_content:
|
||||
try:
|
||||
|
|
@ -1389,6 +1391,8 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
|||
for part in parts:
|
||||
if "text" in part:
|
||||
text_content = part["text"]
|
||||
if text_content is None:
|
||||
continue
|
||||
# Check if text content contains audio data URI
|
||||
if text_content.startswith("data:audio") and ";base64," in text_content:
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue