From 1de72302f3d50830c73d294cd3b3fce86ef0f246 Mon Sep 17 00:00:00 2001 From: Jeeho Lee Date: Sat, 17 Oct 2026 07:30:33 +0000 Subject: [PATCH 1/2] Python: Make the URI content example runnable --- python/packages/core/agent_framework/_types.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/python/packages/core/agent_framework/_types.py b/python/packages/core/agent_framework/_types.py index 3106e91ba40..09e2a353144 100644 --- a/python/packages/core/agent_framework/_types.py +++ b/python/packages/core/agent_framework/_types.py @@ -1049,10 +1049,10 @@ def from_uri( Examples: .. code-block:: python - from agent_framework import Content + from agent_framework import Content, detect_media_type_from_base64 # Create from a data URI - content = Content.from_uri(uri="data:image/png;base64,iVBORw0KGgo...", media_type="image/png") + content = Content.from_uri(uri="data:image/png;base64,iVBORw0KGgo=", media_type="image/png") assert content.type == "data" # Create from an external URI @@ -1060,12 +1060,9 @@ def from_uri( assert content.type == "uri" # When receiving a raw already encode data string, you can do this: - raw_base64_string = "iVBORw0KGgo..." - content = Content.from_uri( - uri=f"data:{(detect_media_type_from_base64(data_str=raw_base64_string) or 'image/png')};base64,{ - raw_base64_string - }" - ) + raw_base64_string = "iVBORw0KGgo=" + media_type = detect_media_type_from_base64(data_str=raw_base64_string) or "image/png" + content = Content.from_uri(uri=f"data:{media_type};base64,{raw_base64_string}") """ return cls( **_validate_uri(uri, media_type), From efcfa0b9916f7bf95133f23c226769b4077ee6f1 Mon Sep 17 00:00:00 2001 From: Jeeho Lee Date: Sun, 18 Oct 2026 02:24:05 +0000 Subject: [PATCH 2/2] Python: Make Content base64 documentation examples runnable --- python/packages/core/agent_framework/_types.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/packages/core/agent_framework/_types.py b/python/packages/core/agent_framework/_types.py index 09e2a353144..a49b1134654 100644 --- a/python/packages/core/agent_framework/_types.py +++ b/python/packages/core/agent_framework/_types.py @@ -984,7 +984,7 @@ def from_data( content = Content.from_data(data=image_bytes, media_type="image/png") # If you have a base64 string and need to detect media type - base64_string = "iVBORw0KGgo..." + base64_string = "iVBORw0KGgo=" media_type = detect_media_type_from_base64(data_str=base64_string) if media_type is None: raise ValueError("Unknown media type") @@ -1023,7 +1023,7 @@ def from_uri( """Create content from a URI, can be both data URI or external URI. Use this when you already have a properly formed data URI - (e.g., "data:image/png;base64,iVBORw0KGgo..."). + (e.g., "data:image/png;base64,iVBORw0KGgo="). Or when you receive a link to a online resource (e.g., "https://example.com/image.png"). Args: