mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Content is marked non empty if its first part contains text or inline_data or file_data or func call/response
PiperOrigin-RevId: 835063599
This commit is contained in:
committed by
Copybara-Service
parent
a3e4ad3cd1
commit
631b58336d
@@ -465,6 +465,43 @@ async def test_events_with_empty_content_are_skipped():
|
||||
author="user",
|
||||
content=types.UserContent("How are you?"),
|
||||
),
|
||||
# Event with content that has only empty text part
|
||||
Event(
|
||||
invocation_id="inv6",
|
||||
author="user",
|
||||
content=types.Content(parts=[types.Part(text="")], role="model"),
|
||||
),
|
||||
# Event with content that has only inline data part
|
||||
Event(
|
||||
invocation_id="inv7",
|
||||
author="user",
|
||||
content=types.Content(
|
||||
parts=[
|
||||
types.Part(
|
||||
inline_data=types.Blob(
|
||||
data=b"test", mime_type="image/png"
|
||||
)
|
||||
)
|
||||
],
|
||||
role="user",
|
||||
),
|
||||
),
|
||||
# Event with content that has only file data part
|
||||
Event(
|
||||
invocation_id="inv8",
|
||||
author="user",
|
||||
content=types.Content(
|
||||
parts=[
|
||||
types.Part(
|
||||
file_data=types.FileData(
|
||||
file_uri="gs://test_bucket/test_file.png",
|
||||
mime_type="image/png",
|
||||
)
|
||||
)
|
||||
],
|
||||
role="user",
|
||||
),
|
||||
),
|
||||
]
|
||||
invocation_context.session.events = events
|
||||
|
||||
@@ -478,4 +515,23 @@ async def test_events_with_empty_content_are_skipped():
|
||||
assert llm_request.contents == [
|
||||
types.UserContent("Hello"),
|
||||
types.UserContent("How are you?"),
|
||||
types.Content(
|
||||
parts=[
|
||||
types.Part(
|
||||
inline_data=types.Blob(data=b"test", mime_type="image/png")
|
||||
)
|
||||
],
|
||||
role="user",
|
||||
),
|
||||
types.Content(
|
||||
parts=[
|
||||
types.Part(
|
||||
file_data=types.FileData(
|
||||
file_uri="gs://test_bucket/test_file.png",
|
||||
mime_type="image/png",
|
||||
)
|
||||
)
|
||||
],
|
||||
role="user",
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user