mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
fix(vertex_and_google_ai_studio.py): only set content if non-empty str
This commit is contained in:
parent
dacc712522
commit
e70d5710d2
2 changed files with 29 additions and 8 deletions
|
@ -587,14 +587,15 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):
|
||||||
_content_str += "data:{};base64,{}".format(
|
_content_str += "data:{};base64,{}".format(
|
||||||
part["inlineData"]["mimeType"], part["inlineData"]["data"]
|
part["inlineData"]["mimeType"], part["inlineData"]["data"]
|
||||||
)
|
)
|
||||||
if part.get("thought") is True:
|
if len(_content_str) > 0:
|
||||||
if reasoning_content_str is None:
|
if part.get("thought") is True:
|
||||||
reasoning_content_str = ""
|
if reasoning_content_str is None:
|
||||||
reasoning_content_str += _content_str
|
reasoning_content_str = ""
|
||||||
else:
|
reasoning_content_str += _content_str
|
||||||
if content_str is None:
|
else:
|
||||||
content_str = ""
|
if content_str is None:
|
||||||
content_str += _content_str
|
content_str = ""
|
||||||
|
content_str += _content_str
|
||||||
|
|
||||||
return content_str, reasoning_content_str
|
return content_str, reasoning_content_str
|
||||||
|
|
||||||
|
|
|
@ -239,3 +239,23 @@ def test_vertex_ai_thinking_output_part():
|
||||||
content, reasoning_content = v.get_assistant_content_message(parts=parts)
|
content, reasoning_content = v.get_assistant_content_message(parts=parts)
|
||||||
assert content == "Hello world"
|
assert content == "Hello world"
|
||||||
assert reasoning_content == "I'm thinking..."
|
assert reasoning_content == "I'm thinking..."
|
||||||
|
|
||||||
|
|
||||||
|
def test_vertex_ai_empty_content():
|
||||||
|
from litellm.llms.vertex_ai.gemini.vertex_and_google_ai_studio_gemini import (
|
||||||
|
VertexGeminiConfig,
|
||||||
|
)
|
||||||
|
from litellm.types.llms.vertex_ai import HttpxPartType
|
||||||
|
|
||||||
|
v = VertexGeminiConfig()
|
||||||
|
parts = [
|
||||||
|
HttpxPartType(
|
||||||
|
functionCall={
|
||||||
|
"name": "get_current_weather",
|
||||||
|
"arguments": "{}",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
|
content, reasoning_content = v.get_assistant_content_message(parts=parts)
|
||||||
|
assert content is None
|
||||||
|
assert reasoning_content is None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue