mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-02 14:22:16 +00:00
fix(fireworks_ai/): fix global disable flag with transform messages helper (#7847)
fixes issue where .get() = none was preventing global disable flag from being picked up
This commit is contained in:
@@ -143,10 +143,8 @@ class FireworksAIConfig(OpenAIGPTConfig):
|
||||
"""
|
||||
disable_add_transform_inline_image_block = cast(
|
||||
Optional[bool],
|
||||
litellm_params.get(
|
||||
"disable_add_transform_inline_image_block",
|
||||
litellm.disable_add_transform_inline_image_block,
|
||||
),
|
||||
litellm_params.get("disable_add_transform_inline_image_block")
|
||||
or litellm.disable_add_transform_inline_image_block,
|
||||
)
|
||||
for message in messages:
|
||||
if message["role"] == "user":
|
||||
|
||||
@@ -196,3 +196,48 @@ def test_global_disable_flag(model, is_disabled, expected_url):
|
||||
)
|
||||
assert result["image_url"] == expected_url
|
||||
litellm.disable_add_transform_inline_image_block = False # Reset for other tests
|
||||
|
||||
|
||||
def test_global_disable_flag_with_transform_messages_helper(monkeypatch):
|
||||
from openai import OpenAI
|
||||
from unittest.mock import patch
|
||||
from litellm import completion
|
||||
|
||||
monkeypatch.setattr(litellm, "disable_add_transform_inline_image_block", True)
|
||||
|
||||
client = OpenAI()
|
||||
|
||||
with patch.object(
|
||||
client.chat.completions.with_raw_response,
|
||||
"create",
|
||||
) as mock_post:
|
||||
try:
|
||||
completion(
|
||||
model="fireworks_ai/accounts/fireworks/models/llama-v3p3-70b-instruct",
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "text", "text": "What's in this image?"},
|
||||
{
|
||||
"type": "image_url",
|
||||
"image_url": {
|
||||
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
],
|
||||
client=client,
|
||||
)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
mock_post.assert_called_once()
|
||||
print(mock_post.call_args.kwargs)
|
||||
assert (
|
||||
"#transform=inline"
|
||||
not in mock_post.call_args.kwargs["messages"][0]["content"][1]["image_url"][
|
||||
"url"
|
||||
]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user