Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ def _convert_agui_content_to_framework(content: Any) -> list[Content]:
converted.append(Content.from_text(text=str(part.get("text", ""))))
continue

if part_type == "input_image":
# Same mapping _normalize_snapshot_content applies to input_image parts.
part = {**part, "type": "image"}
part_type = "image"

if part_type in {"binary", "image", "audio", "video", "document"}:
media_content = _parse_multimodal_media_part(part)
if media_content is not None:
Expand Down
17 changes: 17 additions & 0 deletions python/packages/ag-ui/tests/ag_ui/test_message_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,23 @@ def test_snapshot_input_image_to_binary():
assert result[0]["content"][0]["type"] == "binary"


def test_convert_content_input_image_is_media_not_text():
"""input_image parts become image content, not the text repr of the part."""
from agent_framework_ag_ui._message_adapters import _convert_agui_content_to_framework

result = _convert_agui_content_to_framework(
[
{"type": "input_image", "source": {"type": "url", "url": "https://example.com/img.png"}},
{"type": "input_text", "text": "what is this?"},
]
)

assert result[0].type == "uri"
assert result[0].uri == "https://example.com/img.png"
assert result[0].media_type == "image/*"
assert result[1].text == "what is this?"


def test_snapshot_mime_type_snake_case():
"""mime_type (snake_case) is normalized to mimeType."""
result = agui_messages_to_snapshot_format(
Expand Down
Loading