mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Update workflow orchestration samples to use AzureOpenAIResponsesClient (#4285)
* Update workflow orchestration samples to use AzureOpenAIResponsesClient * Fix broken link
This commit is contained in:
committed by
GitHub
Unverified
parent
cfaa0c6283
commit
8e2cc4bedc
@@ -18,10 +18,11 @@ Run with:
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from agent_framework.azure import AzureOpenAIChatClient
|
||||
from agent_framework.azure import AzureOpenAIResponsesClient
|
||||
from agent_framework.declarative import WorkflowFactory
|
||||
from azure.identity import AzureCliCredential
|
||||
from pydantic import BaseModel, Field
|
||||
@@ -196,8 +197,12 @@ def format_order_confirmation(order_data: dict[str, Any], order_calculation: dic
|
||||
|
||||
async def main():
|
||||
"""Run the agent to function tool workflow."""
|
||||
# Create Azure OpenAI client
|
||||
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
|
||||
# Create Azure OpenAI Responses client
|
||||
chat_client = AzureOpenAIResponsesClient(
|
||||
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
|
||||
deployment_name=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
|
||||
credential=AzureCliCredential(),
|
||||
)
|
||||
|
||||
# Create the order analysis agent with structured output
|
||||
order_analysis_agent = chat_client.as_agent(
|
||||
|
||||
@@ -6,7 +6,7 @@ This sample demonstrates an agent with function tools responding to user queries
|
||||
|
||||
The workflow showcases:
|
||||
- **Function Tools**: Agent equipped with tools to query menu data
|
||||
- **Real Azure OpenAI Agent**: Uses `AzureOpenAIChatClient` to create an agent with tools
|
||||
- **Real Azure OpenAI Agent**: Uses `AzureOpenAIResponsesClient` to create an agent with tools
|
||||
- **Agent Registration**: Shows how to register agents with the `WorkflowFactory`
|
||||
|
||||
## Tools
|
||||
@@ -72,7 +72,11 @@ Session Complete
|
||||
|
||||
```python
|
||||
# Create the agent with tools
|
||||
client = AzureOpenAIChatClient(credential=AzureCliCredential())
|
||||
client = AzureOpenAIResponsesClient(
|
||||
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
|
||||
deployment_name=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
|
||||
credential=AzureCliCredential(),
|
||||
)
|
||||
menu_agent = client.as_agent(
|
||||
name="MenuAgent",
|
||||
instructions="You are a helpful restaurant menu assistant...",
|
||||
|
||||
Reference in New Issue
Block a user