mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-23 00:41:40 +00:00
fix(azure): satisfy type-check gate in file and image format stripping
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
f925c1d1e6
commit
d993014dc6
1 changed files with 4 additions and 5 deletions
|
|
@ -1067,13 +1067,12 @@ def _azure_tool_call_invoke_helper(
|
|||
def _azure_image_url_helper(content: ChatCompletionImageObject):
|
||||
if isinstance(content["image_url"], str):
|
||||
content["image_url"] = {"url": content["image_url"]}
|
||||
elif isinstance(content["image_url"], dict):
|
||||
else:
|
||||
content["image_url"].pop("format", None)
|
||||
|
||||
|
||||
def _azure_file_helper(content: ChatCompletionFileObject) -> None:
|
||||
if isinstance(content.get("file"), dict):
|
||||
content["file"].pop("format", None)
|
||||
content.get("file", {}).pop("format", None)
|
||||
|
||||
|
||||
def convert_to_azure_openai_messages(
|
||||
|
|
@ -1088,9 +1087,9 @@ def convert_to_azure_openai_messages(
|
|||
if m["role"] == "user" and isinstance(m.get("content"), list):
|
||||
for content in m.get("content", []):
|
||||
if isinstance(content, dict) and content.get("type") == "image_url":
|
||||
_azure_image_url_helper(content)
|
||||
_azure_image_url_helper(cast(ChatCompletionImageObject, content))
|
||||
elif isinstance(content, dict) and content.get("type") == "file":
|
||||
_azure_file_helper(content)
|
||||
_azure_file_helper(cast(ChatCompletionFileObject, content))
|
||||
return messages
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue