Python: Removed DefaultAzureCredential (#490)

* Removed DefaultAzureCredential

* Renamed ad_credential to credential
This commit is contained in:
Dmytro Struk
2025-08-26 08:33:17 -07:00
committed by GitHub
Unverified
parent 20d861076a
commit fa88641263
36 changed files with 230 additions and 148 deletions
@@ -5,7 +5,7 @@ from random import randint
from typing import Annotated
from agent_framework.azure import AzureChatClient
from azure.identity import DefaultAzureCredential
from azure.identity import AzureCliCredential
from pydantic import Field
@@ -22,7 +22,9 @@ async def non_streaming_example() -> None:
print("=== Non-streaming Response Example ===")
# Create agent with Azure Chat Client
agent = AzureChatClient(ad_credential=DefaultAzureCredential()).create_agent(
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option.
agent = AzureChatClient(credential=AzureCliCredential()).create_agent(
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -38,7 +40,9 @@ async def streaming_example() -> None:
print("=== Streaming Response Example ===")
# Create agent with Azure Chat Client
agent = AzureChatClient(ad_credential=DefaultAzureCredential()).create_agent(
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option.
agent = AzureChatClient(credential=AzureCliCredential()).create_agent(
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -7,7 +7,7 @@ from typing import Annotated
from agent_framework import ChatClientAgent
from agent_framework.azure import AzureChatClient
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=AzureChatClient(ad_credential=DefaultAzureCredential()),
chat_client=AzureChatClient(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=AzureChatClient(ad_credential=DefaultAzureCredential()),
chat_client=AzureChatClient(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=AzureChatClient(ad_credential=DefaultAzureCredential()),
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a comprehensive assistant that can help with various information requests.",
tools=[get_weather], # Base tool available for all queries
)
@@ -6,7 +6,7 @@ from typing import Annotated
from agent_framework import AgentThread, ChatClientAgent, ChatMessageList
from agent_framework.azure import AzureChatClient
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 (service-managed thread)."""
print("=== Automatic Thread Creation Example ===")
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option.
agent = ChatClientAgent(
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -47,8 +49,10 @@ async def example_with_thread_persistence() -> None:
print("=== Thread Persistence Example ===")
print("Using the same thread across multiple conversations to maintain context.\n")
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option.
agent = ChatClientAgent(
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -80,8 +84,10 @@ async def example_with_existing_thread_messages() -> None:
"""Example showing how to work with existing thread messages for Azure."""
print("=== Existing Thread Messages Example ===")
# For authentication, run `az login` command in terminal or replace AzureCliCredential with preferred
# authentication option.
agent = ChatClientAgent(
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -104,7 +110,7 @@ async def example_with_existing_thread_messages() -> None:
# Create a new agent instance but use the existing thread with its message history
new_agent = ChatClientAgent(
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
chat_client=AzureChatClient(credential=AzureCliCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)