mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Removed DefaultAzureCredential (#490)
* Removed DefaultAzureCredential * Renamed ad_credential to credential
This commit is contained in:
committed by
GitHub
Unverified
parent
20d861076a
commit
fa88641263
+7
-3
@@ -5,7 +5,7 @@ from random import randint
|
||||
from typing import Annotated
|
||||
|
||||
from agent_framework.azure import AzureResponsesClient
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.identity import AzureCliCredential
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
@@ -21,7 +21,9 @@ async def non_streaming_example() -> None:
|
||||
"""Example of non-streaming response (get the complete result at once)."""
|
||||
print("=== Non-streaming Response Example ===")
|
||||
|
||||
agent = AzureResponsesClient(ad_credential=DefaultAzureCredential()).create_agent(
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = AzureResponsesClient(credential=AzureCliCredential()).create_agent(
|
||||
instructions="You are a helpful weather agent.",
|
||||
tools=get_weather,
|
||||
)
|
||||
@@ -36,7 +38,9 @@ async def streaming_example() -> None:
|
||||
"""Example of streaming response (get results as they are generated)."""
|
||||
print("=== Streaming Response Example ===")
|
||||
|
||||
agent = AzureResponsesClient(ad_credential=DefaultAzureCredential()).create_agent(
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = AzureResponsesClient(credential=AzureCliCredential()).create_agent(
|
||||
instructions="You are a helpful weather agent.",
|
||||
tools=get_weather,
|
||||
)
|
||||
|
||||
+4
-2
@@ -4,7 +4,7 @@ import asyncio
|
||||
|
||||
from agent_framework import ChatClientAgent, ChatResponse, HostedCodeInterpreterTool
|
||||
from agent_framework.azure import AzureResponsesClient
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.identity import AzureCliCredential
|
||||
from openai.types.responses.response import Response as OpenAIResponse
|
||||
from openai.types.responses.response_code_interpreter_tool_call import ResponseCodeInterpreterToolCall
|
||||
|
||||
@@ -13,8 +13,10 @@ async def main() -> None:
|
||||
"""Example showing how to use the HostedCodeInterpreterTool with Azure OpenAI Responses."""
|
||||
print("=== Azure OpenAI Responses Agent with Code Interpreter Example ===")
|
||||
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a helpful assistant that can write and execute Python code to solve problems.",
|
||||
tools=HostedCodeInterpreterTool(),
|
||||
)
|
||||
|
||||
+10
-4
@@ -7,7 +7,7 @@ from typing import Annotated
|
||||
|
||||
from agent_framework import ChatClientAgent
|
||||
from agent_framework.azure import AzureResponsesClient
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.identity import AzureCliCredential
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
@@ -31,8 +31,10 @@ async def tools_on_agent_level() -> None:
|
||||
|
||||
# Tools are provided when creating the agent
|
||||
# The agent can use these tools for any query during its lifetime
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a helpful assistant that can provide weather and time information.",
|
||||
tools=[get_weather, get_time], # Tools defined at agent creation
|
||||
)
|
||||
@@ -61,8 +63,10 @@ async def tools_on_run_level() -> None:
|
||||
print("=== Tools Passed to Run Method ===")
|
||||
|
||||
# Agent created without tools
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a helpful assistant.",
|
||||
# No tools defined here
|
||||
)
|
||||
@@ -91,8 +95,10 @@ async def mixed_tools_example() -> None:
|
||||
print("=== Mixed Tools Example (Agent + Run Method) ===")
|
||||
|
||||
# Agent created with some base tools
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a comprehensive assistant that can help with various information requests.",
|
||||
tools=[get_weather], # Base tool available for all queries
|
||||
)
|
||||
|
||||
+11
-5
@@ -6,7 +6,7 @@ from typing import Annotated
|
||||
|
||||
from agent_framework import AgentThread, ChatClientAgent
|
||||
from agent_framework.azure import AzureResponsesClient
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.identity import AzureCliCredential
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
@@ -22,8 +22,10 @@ async def example_with_automatic_thread_creation() -> None:
|
||||
"""Example showing automatic thread creation."""
|
||||
print("=== Automatic Thread Creation Example ===")
|
||||
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a helpful weather agent.",
|
||||
tools=get_weather,
|
||||
)
|
||||
@@ -49,8 +51,10 @@ async def example_with_thread_persistence_in_memory() -> None:
|
||||
"""
|
||||
print("=== Thread Persistence Example (In-Memory) ===")
|
||||
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a helpful weather agent.",
|
||||
tools=get_weather,
|
||||
)
|
||||
@@ -91,8 +95,10 @@ async def example_with_existing_thread_id() -> None:
|
||||
# First, create a conversation and capture the thread ID
|
||||
existing_thread_id = None
|
||||
|
||||
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
|
||||
# authentication option.
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a helpful weather agent.",
|
||||
tools=get_weather,
|
||||
)
|
||||
@@ -115,7 +121,7 @@ async def example_with_existing_thread_id() -> None:
|
||||
print("\n--- Continuing with the same thread ID in a new agent instance ---")
|
||||
|
||||
agent = ChatClientAgent(
|
||||
chat_client=AzureResponsesClient(ad_credential=DefaultAzureCredential()),
|
||||
chat_client=AzureResponsesClient(credential=AzureCliCredential()),
|
||||
instructions="You are a helpful weather agent.",
|
||||
tools=get_weather,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user