From 3e0bc08aade3a41319c243d1432c513e32f0414d Mon Sep 17 00:00:00 2001 From: Laveesh Rohra Date: Thu, 13 Nov 2025 15:15:28 -0800 Subject: [PATCH] Try other clients --- .../azure_functions/01_single_agent/function_app.py | 7 ++++--- .../azure_functions/02_multi_agent/function_app.py | 7 +++---- .../azure_functions/03_callbacks/function_app.py | 7 +++---- .../function_app.py | 9 ++++----- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/python/samples/getting_started/azure_functions/01_single_agent/function_app.py b/python/samples/getting_started/azure_functions/01_single_agent/function_app.py index 1fafdfbddc..eb0fc4dbbc 100644 --- a/python/samples/getting_started/azure_functions/01_single_agent/function_app.py +++ b/python/samples/getting_started/azure_functions/01_single_agent/function_app.py @@ -8,13 +8,14 @@ Prerequisites: set `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_CHAT_DEPLOYMENT_NAM from typing import Any -from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient -from azure.identity import AzureCliCredential +from agent_framework.azure import AgentFunctionApp +from agent_framework.anthropic import AnthropicClient + # 1. Instantiate the agent with the chosen deployment and instructions. def _create_agent() -> Any: """Create the Joker agent.""" - return AzureOpenAIChatClient(credential=AzureCliCredential()).create_agent( + return AnthropicClient().create_agent( name="Joker", instructions="You are good at telling jokes.", ) diff --git a/python/samples/getting_started/azure_functions/02_multi_agent/function_app.py b/python/samples/getting_started/azure_functions/02_multi_agent/function_app.py index afb28667ee..382de7b150 100644 --- a/python/samples/getting_started/azure_functions/02_multi_agent/function_app.py +++ b/python/samples/getting_started/azure_functions/02_multi_agent/function_app.py @@ -12,6 +12,7 @@ import logging from typing import Any from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient +from agent_framework.openai import OpenAIChatClient from azure.identity import AzureCliCredential logger = logging.getLogger(__name__) @@ -50,15 +51,13 @@ def calculate_tip(bill_amount: float, tip_percentage: float = 15.0) -> dict[str, # 1. Create multiple agents, each with its own instruction set and tools. -chat_client = AzureOpenAIChatClient(credential=AzureCliCredential()) - -weather_agent = chat_client.create_agent( +weather_agent = AzureOpenAIChatClient(credential=AzureCliCredential()).create_agent( name="WeatherAgent", instructions="You are a helpful weather assistant. Provide current weather information.", tools=[get_weather], ) -math_agent = chat_client.create_agent( +math_agent = OpenAIChatClient().create_agent( name="MathAgent", instructions="You are a helpful math assistant. Help users with calculations like tip calculations.", tools=[calculate_tip], diff --git a/python/samples/getting_started/azure_functions/03_callbacks/function_app.py b/python/samples/getting_started/azure_functions/03_callbacks/function_app.py index 1ac3588724..186fb27e7b 100644 --- a/python/samples/getting_started/azure_functions/03_callbacks/function_app.py +++ b/python/samples/getting_started/azure_functions/03_callbacks/function_app.py @@ -19,10 +19,9 @@ from agent_framework import AgentRunResponseUpdate from agent_framework.azure import ( AgentCallbackContext, AgentFunctionApp, - AgentResponseCallbackProtocol, - AzureOpenAIChatClient, + AgentResponseCallbackProtocol ) -from azure.identity import AzureCliCredential +from agent_framework.openai import OpenAIResponsesClient logger = logging.getLogger(__name__) @@ -110,7 +109,7 @@ class ConversationAuditTrail(AgentResponseCallbackProtocol): # 2. Create the agent that will emit streaming updates and final responses. -callback_agent = AzureOpenAIChatClient(credential=AzureCliCredential()).create_agent( +callback_agent = OpenAIResponsesClient().create_agent( name="CallbackAgent", instructions=( "You are a friendly assistant that narrates actions while responding. " diff --git a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py index a5991e76f5..573c005600 100644 --- a/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py +++ b/python/samples/getting_started/azure_functions/06_multi_agent_orchestration_conditionals/function_app.py @@ -16,9 +16,9 @@ from typing import Any, cast import azure.durable_functions as df import azure.functions as func -from agent_framework.azure import AgentFunctionApp, AzureOpenAIChatClient +from agent_framework.azure import AgentFunctionApp +from agent_framework.openai import OpenAIChatClient, OpenAIResponsesClient from azure.durable_functions import DurableOrchestrationContext -from azure.identity import AzureCliCredential from pydantic import BaseModel, ValidationError logger = logging.getLogger(__name__) @@ -43,14 +43,13 @@ class EmailPayload(BaseModel): # 2. Instantiate both agents so they can be registered with AgentFunctionApp. def _create_agents() -> list[Any]: - chat_client = AzureOpenAIChatClient(credential=AzureCliCredential()) - spam_agent = chat_client.create_agent( + spam_agent = OpenAIChatClient().create_agent( name=SPAM_AGENT_NAME, instructions="You are a spam detection assistant that identifies spam emails.", ) - email_agent = chat_client.create_agent( + email_agent = OpenAIResponsesClient().create_agent( name=EMAIL_AGENT_NAME, instructions="You are an email assistant that helps users draft responses to emails with professionalism.", )