Repository navigation
fix(azure): strip litellm format field from file and image content parts #41275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f925c1d
d993014
81524d2
f219535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -307,3 +307,38 @@ def test_request_without_tools_is_unchanged(self): | |
| ) | ||
| assert "tools" not in request | ||
| assert request["temperature"] == 0.2 | ||
|
|
||
|
|
||
| def test_transform_request_strips_litellm_format_from_managed_file_id(): | ||
| """update_messages_with_model_file_ids writes file.format = MIME type, which Azure rejects""" | ||
| import base64 | ||
|
|
||
| from litellm.litellm_core_utils.prompt_templates.common_utils import ( | ||
| update_messages_with_model_file_ids, | ||
| ) | ||
|
|
||
| managed_file_id: Final = base64.b64encode( | ||
| b"litellm_proxy:application/pdf;unified_id,abc123;llm_output_file_id,assistant-xyz;target_model_names,azure-gpt" | ||
| ).decode() | ||
| messages = [ | ||
| { | ||
| "role": "user", | ||
| "content": [ | ||
| {"type": "text", "text": "Summarize this file"}, | ||
| {"type": "file", "file": {"file_id": managed_file_id}}, | ||
| ], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reassigning Context Used: CLAUDE.md (source) Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
| } | ||
| ] | ||
| messages = update_messages_with_model_file_ids(messages, None, {}) | ||
|
|
||
| request = AzureOpenAIConfig().transform_request( | ||
| model="gpt-5.4", | ||
| messages=messages, | ||
| optional_params={}, | ||
| litellm_params={}, | ||
| headers={}, | ||
| ) | ||
|
|
||
| file_part = request["messages"][0]["content"][1]["file"] | ||
| assert "format" not in file_part | ||
| assert file_part["file_id"] == "assistant-xyz" | ||
Uh oh!
There was an error while loading. Please reload this page.