Skip to content

Commit 4b88635

Browse files
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
1 parent 05f476d commit 4b88635

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

litellm/llms/fireworks_ai/chat/transformation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,8 @@ def _transform_messages_helper(
143143
"""
144144
disable_add_transform_inline_image_block = cast(
145145
Optional[bool],
146-
litellm_params.get(
147-
"disable_add_transform_inline_image_block",
148-
litellm.disable_add_transform_inline_image_block,
149-
),
146+
litellm_params.get("disable_add_transform_inline_image_block")
147+
or litellm.disable_add_transform_inline_image_block,
150148
)
151149
for message in messages:
152150
if message["role"] == "user":

tests/llm_translation/test_fireworks_ai_translation.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,48 @@ def test_global_disable_flag(model, is_disabled, expected_url):
196196
)
197197
assert result["image_url"] == expected_url
198198
litellm.disable_add_transform_inline_image_block = False # Reset for other tests
199+
200+
201+
def test_global_disable_flag_with_transform_messages_helper(monkeypatch):
202+
from openai import OpenAI
203+
from unittest.mock import patch
204+
from litellm import completion
205+
206+
monkeypatch.setattr(litellm, "disable_add_transform_inline_image_block", True)
207+
208+
client = OpenAI()
209+
210+
with patch.object(
211+
client.chat.completions.with_raw_response,
212+
"create",
213+
) as mock_post:
214+
try:
215+
completion(
216+
model="fireworks_ai/accounts/fireworks/models/llama-v3p3-70b-instruct",
217+
messages=[
218+
{
219+
"role": "user",
220+
"content": [
221+
{"type": "text", "text": "What's in this image?"},
222+
{
223+
"type": "image_url",
224+
"image_url": {
225+
"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"
226+
},
227+
},
228+
],
229+
}
230+
],
231+
client=client,
232+
)
233+
except Exception as e:
234+
print(e)
235+
236+
mock_post.assert_called_once()
237+
print(mock_post.call_args.kwargs)
238+
assert (
239+
"#transform=inline"
240+
not in mock_post.call_args.kwargs["messages"][0]["content"][1]["image_url"][
241+
"url"
242+
]
243+
)

0 commit comments

Comments
 (0)