Skip to content

Commit 90a0e69

Browse files
committed
fix: accept Azure assistant file ids
1 parent 3329ced commit 90a0e69

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/google/adk/models/lite_llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ def _infer_mime_type_from_uri(uri: str) -> Optional[str]:
281281

282282
def _looks_like_openai_file_id(file_uri: str) -> bool:
283283
"""Returns True when file_uri resembles an OpenAI/Azure file id."""
284-
return file_uri.startswith("file-")
284+
return file_uri.startswith(("file-", "assistant-"))
285285

286286

287287
def _is_http_url(uri: str) -> bool:

tests/unittests/models/test_litellm.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,6 +2943,20 @@ async def test_get_content_file_uri_file_id_required_preserves_file_id(
29432943
assert content == [{"type": "file", "file": {"file_id": "file-abc123"}}]
29442944

29452945

2946+
@pytest.mark.asyncio
2947+
async def test_get_content_file_uri_azure_preserves_assistant_file_id():
2948+
parts = [
2949+
types.Part(
2950+
file_data=types.FileData(
2951+
file_uri="assistant-abc123",
2952+
mime_type="application/pdf",
2953+
)
2954+
)
2955+
]
2956+
content = await _get_content(parts, provider="azure", model="azure/gpt-4.1")
2957+
assert content == [{"type": "file", "file": {"file_id": "assistant-abc123"}}]
2958+
2959+
29462960
@pytest.mark.asyncio
29472961
@pytest.mark.parametrize(
29482962
"provider,model",

0 commit comments

Comments
 (0)