mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix broken Content API imports in Python samples (#3639)
* Initial plan * Fix broken import paths for Content API in all Python sample files Co-authored-by: moonbox3 <35585003+moonbox3@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: moonbox3 <35585003+moonbox3@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
f56218fa1e
commit
96d3f2a55e
+3
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
import asyncio
|
||||
|
||||
from agent_framework import ChatMessage, TextContent, UriContent
|
||||
from agent_framework import ChatMessage, Content
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
|
||||
"""
|
||||
@@ -26,8 +26,8 @@ async def main():
|
||||
user_message = ChatMessage(
|
||||
role="user",
|
||||
contents=[
|
||||
TextContent(text="What do you see in this image?"),
|
||||
UriContent(
|
||||
Content.from_text(text="What do you see in this image?"),
|
||||
Content.from_uri(
|
||||
uri="https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
|
||||
media_type="image/jpeg",
|
||||
),
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
import asyncio
|
||||
import base64
|
||||
|
||||
from agent_framework import DataContent, HostedImageGenerationTool, ImageGenerationToolResultContent, UriContent
|
||||
from agent_framework import Content, HostedImageGenerationTool, ImageGenerationToolResultContent
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
|
||||
"""
|
||||
@@ -72,7 +72,7 @@ async def main() -> None:
|
||||
for content in message.contents:
|
||||
if isinstance(content, ImageGenerationToolResultContent) and content.outputs:
|
||||
for output in content.outputs:
|
||||
if isinstance(output, (DataContent, UriContent)) and output.uri:
|
||||
if output.type in ("data", "uri") and output.uri:
|
||||
show_image_info(output.uri)
|
||||
break
|
||||
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ import asyncio
|
||||
import base64
|
||||
|
||||
import anyio
|
||||
from agent_framework import DataContent, HostedImageGenerationTool
|
||||
from agent_framework import Content, HostedImageGenerationTool
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
|
||||
"""OpenAI Responses Client Streaming Image Generation Example
|
||||
@@ -72,7 +72,7 @@ async def main():
|
||||
# Handle partial images
|
||||
# The final partial image IS the complete, full-quality image. Each partial
|
||||
# represents a progressive refinement, with the last one being the finished result.
|
||||
if isinstance(content, DataContent) and content.additional_properties.get("is_partial_image"):
|
||||
if content.type == "data" and content.additional_properties.get("is_partial_image"):
|
||||
print(f" Image {image_count} received")
|
||||
|
||||
# Extract file extension from media_type (e.g., "image/png" -> "png")
|
||||
|
||||
+3
-3
@@ -6,8 +6,8 @@ from agent_framework import (
|
||||
ChatAgent,
|
||||
CodeInterpreterToolCallContent,
|
||||
CodeInterpreterToolResultContent,
|
||||
Content,
|
||||
HostedCodeInterpreterTool,
|
||||
TextContent,
|
||||
tool,
|
||||
)
|
||||
from agent_framework.openai import OpenAIResponsesClient
|
||||
@@ -41,13 +41,13 @@ async def main() -> None:
|
||||
if code_blocks:
|
||||
code_inputs = code_blocks[0].inputs or []
|
||||
for content in code_inputs:
|
||||
if isinstance(content, TextContent):
|
||||
if content.type == "text":
|
||||
print(f"Generated code:\n{content.text}")
|
||||
break
|
||||
if outputs:
|
||||
print("Execution outputs:")
|
||||
for out in outputs[0].outputs or []:
|
||||
if isinstance(out, TextContent):
|
||||
if out.type == "text":
|
||||
print(out.text)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user