mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Properly configure structured outputs based on new options dict (#3213)
* Properly configure structured outputs based on new options dict * Fix mypy
This commit is contained in:
committed by
GitHub
Unverified
parent
620da7a829
commit
15d0c34d9f
@@ -34,7 +34,7 @@ async def main() -> None:
|
||||
name="ProductMarketerAgent",
|
||||
instructions="Return launch briefs as structured JSON.",
|
||||
# Specify type to use as response
|
||||
response_format=ReleaseBrief,
|
||||
options={"response_format": ReleaseBrief},
|
||||
)
|
||||
|
||||
query = "Draft a launch brief for the Contoso Note app."
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ async def non_streaming_example() -> None:
|
||||
print(f"User: {query}")
|
||||
|
||||
# Get structured response from the agent using response_format parameter
|
||||
result = await agent.run(query, response_format=OutputStruct)
|
||||
result = await agent.run(query, options={"response_format": OutputStruct})
|
||||
|
||||
# Access the structured output directly from the response value
|
||||
if result.value:
|
||||
@@ -63,7 +63,7 @@ async def streaming_example() -> None:
|
||||
# Get structured response from streaming agent using AgentResponse.from_agent_response_generator
|
||||
# This method collects all streaming updates and combines them into a single AgentResponse
|
||||
result = await AgentResponse.from_agent_response_generator(
|
||||
agent.run_stream(query, response_format=OutputStruct),
|
||||
agent.run_stream(query, options={"response_format": OutputStruct}),
|
||||
output_format_type=OutputStruct,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user