Renamed async_credential to credential (#2648)

This commit is contained in:
Dmytro Struk
2025-12-07 17:21:18 -08:00
committed by GitHub
Unverified
parent eb06faea2d
commit cfcb71334a
64 changed files with 266 additions and 269 deletions
@@ -34,7 +34,7 @@ async def non_streaming_example() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -56,7 +56,7 @@ async def streaming_example() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="WeatherAgent",
instructions="You are a helpful weather agent.",
tools=get_weather,
@@ -39,7 +39,7 @@ async def main() -> None:
# 2. Use AzureAIAgentClient as async context manager for automatic cleanup
async with (
AzureAIAgentClient(async_credential=AzureCliCredential()) as client,
AzureAIAgentClient(credential=AzureCliCredential()) as client,
ChatAgent(
chat_client=client,
name="BingSearchAgent",
@@ -34,7 +34,7 @@ async def main() -> None:
# 2. Use AzureAIAgentClient as async context manager for automatic cleanup
async with (
AzureAIAgentClient(async_credential=AzureCliCredential()) as client,
AzureAIAgentClient(credential=AzureCliCredential()) as client,
ChatAgent(
chat_client=client,
name="BingSearchAgent",
@@ -39,7 +39,7 @@ async def main() -> None:
# authentication option.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential) as chat_client,
AzureAIAgentClient(credential=credential) as chat_client,
):
agent = chat_client.create_agent(
name="CodingAgent",
@@ -39,7 +39,7 @@ async def main() -> None:
chat_client=AzureAIAgentClient(
project_endpoint=os.environ["AZURE_AI_PROJECT_ENDPOINT"],
model_deployment_name=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
async_credential=credential,
credential=credential,
agent_name="WeatherAgent",
should_cleanup_agent=True, # Set to False if you want to disable automatic agent cleanup
),
@@ -24,7 +24,7 @@ USER_INPUTS = [
async def main() -> None:
"""Main function demonstrating Azure AI agent with file search capabilities."""
client = AzureAIAgentClient(async_credential=AzureCliCredential())
client = AzureAIAgentClient(credential=AzureCliCredential())
file: FileInfo | None = None
vector_store: VectorStore | None = None
@@ -74,7 +74,7 @@ async def main() -> None:
# 6. Cleanup: Delete the vector store and file in case of earlier failure to prevent orphaned resources.
# Refreshing the client is required since chat agent closes it
client = AzureAIAgentClient(async_credential=AzureCliCredential())
client = AzureAIAgentClient(credential=AzureCliCredential())
try:
if vector_store:
await client.agents_client.vector_stores.delete(vector_store.id)
@@ -43,7 +43,7 @@ async def tools_on_agent_level() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful assistant that can provide weather and time information.",
tools=[get_weather, get_time], # Tools defined at agent creation
) as agent,
@@ -77,7 +77,7 @@ async def tools_on_run_level() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful assistant.",
# No tools defined here
) as agent,
@@ -111,7 +111,7 @@ async def mixed_tools_example() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a comprehensive assistant that can help with various information requests.",
tools=[get_weather], # Base tool available for all queries
) as agent,
@@ -42,7 +42,7 @@ async def main() -> None:
"""Example showing Hosted MCP tools for a Azure AI Agent."""
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential) as chat_client,
AzureAIAgentClient(credential=credential) as chat_client,
):
agent = chat_client.create_agent(
name="DocsAgent",
@@ -28,7 +28,7 @@ async def mcp_tools_on_run_level() -> None:
url="https://learn.microsoft.com/api/mcp",
) as mcp_server,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
name="DocsAgent",
instructions="You are a helpful assistant that can help with microsoft documentation questions.",
) as agent,
@@ -55,7 +55,7 @@ async def mcp_tools_on_agent_level() -> None:
# The agent will connect to the MCP server through its context manager.
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential).create_agent(
AzureAIAgentClient(credential=credential).create_agent(
name="DocsAgent",
instructions="You are a helpful assistant that can help with microsoft documentation questions.",
tools=MCPStreamableHTTPTool( # Tools defined at agent creation
@@ -67,7 +67,7 @@ async def main() -> None:
"""Example showing Hosted MCP tools for a Azure AI Agent."""
async with (
AzureCliCredential() as credential,
AzureAIAgentClient(async_credential=credential) as chat_client,
AzureAIAgentClient(credential=credential) as chat_client,
):
agent = chat_client.create_agent(
name="DocsAgent",
@@ -41,7 +41,7 @@ async def main() -> None:
weather_openapi_spec, countries_openapi_spec = load_openapi_specs()
# 2. Use AzureAIAgentClient as async context manager for automatic cleanup
async with AzureAIAgentClient(async_credential=AzureCliCredential()) as client:
async with AzureAIAgentClient(credential=AzureCliCredential()) as client:
# 3. Create OpenAPI tools using Azure AI's OpenApiTool
auth = OpenApiAnonymousAuthDetails()
@@ -34,7 +34,7 @@ async def example_with_automatic_thread_creation() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,
@@ -63,7 +63,7 @@ async def example_with_thread_persistence() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,
@@ -104,7 +104,7 @@ async def example_with_existing_thread_id() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(async_credential=credential),
chat_client=AzureAIAgentClient(credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,
@@ -127,7 +127,7 @@ async def example_with_existing_thread_id() -> None:
async with (
AzureCliCredential() as credential,
ChatAgent(
chat_client=AzureAIAgentClient(thread_id=existing_thread_id, async_credential=credential),
chat_client=AzureAIAgentClient(thread_id=existing_thread_id, credential=credential),
instructions="You are a helpful weather agent.",
tools=get_weather,
) as agent,