Skip to content

Commit 97087b9

Browse files
committed
Piggyback txt
1 parent 2dc2a0e commit 97087b9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/google/adk/models/lite_llm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
}
8181

8282
_SUPPORTED_FILE_CONTENT_MIME_TYPES = set(
83-
["application/pdf", "application/json"]
83+
["application/pdf", "application/json", "text/plain"]
8484
)
8585

8686

tests/unittests/models/test_litellm.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
FILE_URI_TEST_CASES = [
9191
pytest.param("gs://bucket/document.pdf", "application/pdf", id="pdf"),
9292
pytest.param("gs://bucket/data.json", "application/json", id="json"),
93+
pytest.param("gs://bucket/data.txt", "text/plain", id="txt"),
9394
]
9495

9596
STREAMING_MODEL_RESPONSE = [
@@ -1328,6 +1329,17 @@ def test_get_content_json():
13281329
assert content[0]["file"]["format"] == "application/json"
13291330

13301331

1332+
def test_get_content_txt():
1333+
parts = [types.Part.from_bytes(data=b"hello world", mime_type="text/plain")]
1334+
content = _get_content(parts)
1335+
assert content[0]["type"] == "file"
1336+
assert (
1337+
content[0]["file"]["file_data"]
1338+
== "data:text/plain;base64,aGVsbG8gd29ybGQ="
1339+
)
1340+
assert content[0]["file"]["format"] == "text/plain"
1341+
1342+
13311343
@pytest.mark.parametrize("file_uri,mime_type", FILE_URI_TEST_CASES)
13321344
def test_get_content_file_uri(file_uri, mime_type):
13331345
parts = [types.Part.from_uri(file_uri=file_uri, mime_type=mime_type)]

0 commit comments

Comments
 (0)