mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Add support for file URIs in LiteLLM content conversion to fix issue #3131
changed the LiteLLM content conversion so Part.file_data.file_uri (like the gs://…) becomes a file object with file_id, making sure GCS-backed files reach LiteLLM proxies instead of being dropped add unit tests covering both _get_content and _content_to_message_param paths for file URIs PiperOrigin-RevId: 817658432
This commit is contained in:
committed by
Copybara-Service
parent
998264a5b1
commit
85ed500871
@@ -65,8 +65,9 @@ _NEW_LINE = "\n"
|
||||
_EXCLUDED_PART_FIELD = {"inline_data": {"data"}}
|
||||
|
||||
|
||||
class ChatCompletionFileUrlObject(TypedDict):
|
||||
class ChatCompletionFileUrlObject(TypedDict, total=False):
|
||||
file_data: str
|
||||
file_id: str
|
||||
format: str
|
||||
|
||||
|
||||
@@ -281,6 +282,16 @@ def _get_content(
|
||||
})
|
||||
else:
|
||||
raise ValueError("LiteLlm(BaseLlm) does not support this content part.")
|
||||
elif part.file_data and part.file_data.file_uri:
|
||||
file_object: ChatCompletionFileUrlObject = {
|
||||
"file_id": part.file_data.file_uri,
|
||||
}
|
||||
if part.file_data.mime_type:
|
||||
file_object["format"] = part.file_data.mime_type
|
||||
content_objects.append({
|
||||
"type": "file",
|
||||
"file": file_object,
|
||||
})
|
||||
|
||||
return content_objects
|
||||
|
||||
|
||||
Reference in New Issue
Block a user