mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: send full MIME types for image/video/pdf in get_content
Use full media types (image/jpeg, video/mp4, application/pdf) instead of suffixes (jpeg/mp4/pdf) when constructing LiteLLM payloads This fxes compatibility with providers that validate media types (Anthropic) Updated and added unit tests to assert full MIME types for image/video/pdf PiperOrigin-RevId: 800685204
This commit is contained in:
committed by
Copybara-Service
parent
11a2ffe35a
commit
e45c3be238
@@ -1036,7 +1036,7 @@ def test_get_content_image():
|
||||
content[0]["image_url"]["url"]
|
||||
== "data:image/png;base64,dGVzdF9pbWFnZV9kYXRh"
|
||||
)
|
||||
assert content[0]["image_url"]["format"] == "png"
|
||||
assert content[0]["image_url"]["format"] == "image/png"
|
||||
|
||||
|
||||
def test_get_content_video():
|
||||
@@ -1049,7 +1049,33 @@ def test_get_content_video():
|
||||
content[0]["video_url"]["url"]
|
||||
== "data:video/mp4;base64,dGVzdF92aWRlb19kYXRh"
|
||||
)
|
||||
assert content[0]["video_url"]["format"] == "mp4"
|
||||
assert content[0]["video_url"]["format"] == "video/mp4"
|
||||
|
||||
|
||||
def test_get_content_pdf():
|
||||
parts = [
|
||||
types.Part.from_bytes(data=b"test_pdf_data", mime_type="application/pdf")
|
||||
]
|
||||
content = _get_content(parts)
|
||||
assert content[0]["type"] == "file"
|
||||
assert (
|
||||
content[0]["file"]["file_data"]
|
||||
== "data:application/pdf;base64,dGVzdF9wZGZfZGF0YQ=="
|
||||
)
|
||||
assert content[0]["file"]["format"] == "application/pdf"
|
||||
|
||||
|
||||
def test_get_content_audio():
|
||||
parts = [
|
||||
types.Part.from_bytes(data=b"test_audio_data", mime_type="audio/mpeg")
|
||||
]
|
||||
content = _get_content(parts)
|
||||
assert content[0]["type"] == "audio_url"
|
||||
assert (
|
||||
content[0]["audio_url"]["url"]
|
||||
== "data:audio/mpeg;base64,dGVzdF9hdWRpb19kYXRh"
|
||||
)
|
||||
assert content[0]["audio_url"]["format"] == "audio/mpeg"
|
||||
|
||||
|
||||
def test_to_litellm_role():
|
||||
|
||||
Reference in New Issue
Block a user