Skip to content

Commit cfcb713

Browse files
authored
Renamed async_credential to credential (#2648)
1 parent eb06fae commit cfcb713

File tree

64 files changed

+260
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+260
-263
lines changed

python/packages/azure-ai/agent_framework_azure_ai/_chat_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(
122122
thread_id: str | None = None,
123123
project_endpoint: str | None = None,
124124
model_deployment_name: str | None = None,
125-
async_credential: AsyncTokenCredential | None = None,
125+
credential: AsyncTokenCredential | None = None,
126126
should_cleanup_agent: bool = True,
127127
env_file_path: str | None = None,
128128
env_file_encoding: str | None = None,
@@ -144,7 +144,7 @@ def __init__(
144144
Ignored when a agents_client is passed.
145145
model_deployment_name: The model deployment name to use for agent creation.
146146
Can also be set via environment variable AZURE_AI_MODEL_DEPLOYMENT_NAME.
147-
async_credential: Azure async credential to use for authentication.
147+
credential: Azure async credential to use for authentication.
148148
should_cleanup_agent: Whether to cleanup (delete) agents created by this client when
149149
the client is closed or context is exited. Defaults to True. Only affects agents
150150
created by this client instance; existing agents passed via agent_id are never deleted.
@@ -162,17 +162,17 @@ def __init__(
162162
# Set AZURE_AI_PROJECT_ENDPOINT=https://your-project.cognitiveservices.azure.com
163163
# Set AZURE_AI_MODEL_DEPLOYMENT_NAME=gpt-4
164164
credential = DefaultAzureCredential()
165-
client = AzureAIAgentClient(async_credential=credential)
165+
client = AzureAIAgentClient(credential=credential)
166166
167167
# Or passing parameters directly
168168
client = AzureAIAgentClient(
169169
project_endpoint="https://your-project.cognitiveservices.azure.com",
170170
model_deployment_name="gpt-4",
171-
async_credential=credential,
171+
credential=credential,
172172
)
173173
174174
# Or loading from a .env file
175-
client = AzureAIAgentClient(async_credential=credential, env_file_path="path/to/.env")
175+
client = AzureAIAgentClient(credential=credential, env_file_path="path/to/.env")
176176
"""
177177
try:
178178
azure_ai_settings = AzureAISettings(
@@ -200,11 +200,11 @@ def __init__(
200200
)
201201

202202
# Use provided credential
203-
if not async_credential:
203+
if not credential:
204204
raise ServiceInitializationError("Azure credential is required when agents_client is not provided.")
205205
agents_client = AgentsClient(
206206
endpoint=azure_ai_settings.project_endpoint,
207-
credential=async_credential,
207+
credential=credential,
208208
user_agent=AGENT_FRAMEWORK_USER_AGENT,
209209
)
210210
should_close_client = True
@@ -214,7 +214,7 @@ def __init__(
214214

215215
# Initialize instance variables
216216
self.agents_client = agents_client
217-
self.credential = async_credential
217+
self.credential = credential
218218
self.agent_id = agent_id
219219
self.agent_name = agent_name
220220
self.agent_description = agent_description

python/packages/azure-ai/agent_framework_azure_ai/_client.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(
6666
conversation_id: str | None = None,
6767
project_endpoint: str | None = None,
6868
model_deployment_name: str | None = None,
69-
async_credential: AsyncTokenCredential | None = None,
69+
credential: AsyncTokenCredential | None = None,
7070
use_latest_version: bool | None = None,
7171
env_file_path: str | None = None,
7272
env_file_encoding: str | None = None,
@@ -86,7 +86,7 @@ def __init__(
8686
Ignored when a project_client is passed.
8787
model_deployment_name: The model deployment name to use for agent creation.
8888
Can also be set via environment variable AZURE_AI_MODEL_DEPLOYMENT_NAME.
89-
async_credential: Azure async credential to use for authentication.
89+
credential: Azure async credential to use for authentication.
9090
use_latest_version: Boolean flag that indicates whether to use latest agent version
9191
if it exists in the service.
9292
env_file_path: Path to environment file for loading settings.
@@ -103,17 +103,17 @@ def __init__(
103103
# Set AZURE_AI_PROJECT_ENDPOINT=https://your-project.cognitiveservices.azure.com
104104
# Set AZURE_AI_MODEL_DEPLOYMENT_NAME=gpt-4
105105
credential = DefaultAzureCredential()
106-
client = AzureAIClient(async_credential=credential)
106+
client = AzureAIClient(credential=credential)
107107
108108
# Or passing parameters directly
109109
client = AzureAIClient(
110110
project_endpoint="https://your-project.cognitiveservices.azure.com",
111111
model_deployment_name="gpt-4",
112-
async_credential=credential,
112+
credential=credential,
113113
)
114114
115115
# Or loading from a .env file
116-
client = AzureAIClient(async_credential=credential, env_file_path="path/to/.env")
116+
client = AzureAIClient(credential=credential, env_file_path="path/to/.env")
117117
"""
118118
try:
119119
azure_ai_settings = AzureAISettings(
@@ -135,11 +135,11 @@ def __init__(
135135
)
136136

137137
# Use provided credential
138-
if not async_credential:
138+
if not credential:
139139
raise ServiceInitializationError("Azure credential is required when project_client is not provided.")
140140
project_client = AIProjectClient(
141141
endpoint=azure_ai_settings.project_endpoint,
142-
credential=async_credential,
142+
credential=credential,
143143
user_agent=AGENT_FRAMEWORK_USER_AGENT,
144144
)
145145
should_close_client = True
@@ -155,7 +155,7 @@ def __init__(
155155
self.agent_description = agent_description
156156
self.use_latest_version = use_latest_version
157157
self.project_client = project_client
158-
self.credential = async_credential
158+
self.credential = credential
159159
self.model_id = azure_ai_settings.model_deployment_name
160160
self.conversation_id = conversation_id
161161

python/packages/azure-ai/tests/test_azure_ai_agent_client.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test_azure_ai_chat_client_init_missing_project_endpoint() -> None:
170170
agent_id=None,
171171
project_endpoint=None, # Missing endpoint
172172
model_deployment_name="test-model",
173-
async_credential=AsyncMock(spec=AsyncTokenCredential),
173+
credential=AsyncMock(spec=AsyncTokenCredential),
174174
)
175175

176176

@@ -190,7 +190,7 @@ def test_azure_ai_chat_client_init_missing_model_deployment_for_agent_creation()
190190
agent_id=None, # No existing agent
191191
project_endpoint="https://test.com",
192192
model_deployment_name=None, # Missing for agent creation
193-
async_credential=AsyncMock(spec=AsyncTokenCredential),
193+
credential=AsyncMock(spec=AsyncTokenCredential),
194194
)
195195

196196

@@ -223,7 +223,7 @@ def test_azure_ai_chat_client_from_dict(mock_agents_client: MagicMock) -> None:
223223

224224

225225
def test_azure_ai_chat_client_init_missing_credential(azure_ai_unit_test_env: dict[str, str]) -> None:
226-
"""Test AzureAIAgentClient.__init__ when async_credential is missing and no agents_client provided."""
226+
"""Test AzureAIAgentClient.__init__ when credential is missing and no agents_client provided."""
227227
with pytest.raises(
228228
ServiceInitializationError, match="Azure credential is required when agents_client is not provided"
229229
):
@@ -232,7 +232,7 @@ def test_azure_ai_chat_client_init_missing_credential(azure_ai_unit_test_env: di
232232
agent_id="existing-agent",
233233
project_endpoint=azure_ai_unit_test_env["AZURE_AI_PROJECT_ENDPOINT"],
234234
model_deployment_name=azure_ai_unit_test_env["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
235-
async_credential=None, # Missing credential
235+
credential=None, # Missing credential
236236
)
237237

238238

@@ -246,7 +246,7 @@ def test_azure_ai_chat_client_init_validation_error(mock_azure_credential: Magic
246246
AzureAIAgentClient(
247247
project_endpoint="https://test.com",
248248
model_deployment_name="test-model",
249-
async_credential=mock_azure_credential,
249+
credential=mock_azure_credential,
250250
)
251251

252252

@@ -1373,7 +1373,7 @@ def get_weather(
13731373
@skip_if_azure_ai_integration_tests_disabled
13741374
async def test_azure_ai_chat_client_get_response() -> None:
13751375
"""Test Azure AI Chat Client response."""
1376-
async with AzureAIAgentClient(async_credential=AzureCliCredential()) as azure_ai_chat_client:
1376+
async with AzureAIAgentClient(credential=AzureCliCredential()) as azure_ai_chat_client:
13771377
assert isinstance(azure_ai_chat_client, ChatClientProtocol)
13781378

13791379
messages: list[ChatMessage] = []
@@ -1398,7 +1398,7 @@ async def test_azure_ai_chat_client_get_response() -> None:
13981398
@skip_if_azure_ai_integration_tests_disabled
13991399
async def test_azure_ai_chat_client_get_response_tools() -> None:
14001400
"""Test Azure AI Chat Client response with tools."""
1401-
async with AzureAIAgentClient(async_credential=AzureCliCredential()) as azure_ai_chat_client:
1401+
async with AzureAIAgentClient(credential=AzureCliCredential()) as azure_ai_chat_client:
14021402
assert isinstance(azure_ai_chat_client, ChatClientProtocol)
14031403

14041404
messages: list[ChatMessage] = []
@@ -1420,7 +1420,7 @@ async def test_azure_ai_chat_client_get_response_tools() -> None:
14201420
@skip_if_azure_ai_integration_tests_disabled
14211421
async def test_azure_ai_chat_client_streaming() -> None:
14221422
"""Test Azure AI Chat Client streaming response."""
1423-
async with AzureAIAgentClient(async_credential=AzureCliCredential()) as azure_ai_chat_client:
1423+
async with AzureAIAgentClient(credential=AzureCliCredential()) as azure_ai_chat_client:
14241424
assert isinstance(azure_ai_chat_client, ChatClientProtocol)
14251425

14261426
messages: list[ChatMessage] = []
@@ -1451,7 +1451,7 @@ async def test_azure_ai_chat_client_streaming() -> None:
14511451
@skip_if_azure_ai_integration_tests_disabled
14521452
async def test_azure_ai_chat_client_streaming_tools() -> None:
14531453
"""Test Azure AI Chat Client streaming response with tools."""
1454-
async with AzureAIAgentClient(async_credential=AzureCliCredential()) as azure_ai_chat_client:
1454+
async with AzureAIAgentClient(credential=AzureCliCredential()) as azure_ai_chat_client:
14551455
assert isinstance(azure_ai_chat_client, ChatClientProtocol)
14561456

14571457
messages: list[ChatMessage] = []
@@ -1479,7 +1479,7 @@ async def test_azure_ai_chat_client_streaming_tools() -> None:
14791479
async def test_azure_ai_chat_client_agent_basic_run() -> None:
14801480
"""Test ChatAgent basic run functionality with AzureAIAgentClient."""
14811481
async with ChatAgent(
1482-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1482+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
14831483
) as agent:
14841484
# Run a simple query
14851485
response = await agent.run("Hello! Please respond with 'Hello World' exactly.")
@@ -1496,7 +1496,7 @@ async def test_azure_ai_chat_client_agent_basic_run() -> None:
14961496
async def test_azure_ai_chat_client_agent_basic_run_streaming() -> None:
14971497
"""Test ChatAgent basic streaming functionality with AzureAIAgentClient."""
14981498
async with ChatAgent(
1499-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1499+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
15001500
) as agent:
15011501
# Run streaming query
15021502
full_message: str = ""
@@ -1516,7 +1516,7 @@ async def test_azure_ai_chat_client_agent_basic_run_streaming() -> None:
15161516
async def test_azure_ai_chat_client_agent_thread_persistence() -> None:
15171517
"""Test ChatAgent thread persistence across runs with AzureAIAgentClient."""
15181518
async with ChatAgent(
1519-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1519+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
15201520
instructions="You are a helpful assistant with good memory.",
15211521
) as agent:
15221522
# Create a new thread that will be reused
@@ -1542,7 +1542,7 @@ async def test_azure_ai_chat_client_agent_thread_persistence() -> None:
15421542
async def test_azure_ai_chat_client_agent_existing_thread_id() -> None:
15431543
"""Test ChatAgent existing thread ID functionality with AzureAIAgentClient."""
15441544
async with ChatAgent(
1545-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1545+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
15461546
instructions="You are a helpful assistant with good memory.",
15471547
) as first_agent:
15481548
# Start a conversation and get the thread ID
@@ -1559,7 +1559,7 @@ async def test_azure_ai_chat_client_agent_existing_thread_id() -> None:
15591559

15601560
# Now continue with the same thread ID in a new agent instance
15611561
async with ChatAgent(
1562-
chat_client=AzureAIAgentClient(thread_id=existing_thread_id, async_credential=AzureCliCredential()),
1562+
chat_client=AzureAIAgentClient(thread_id=existing_thread_id, credential=AzureCliCredential()),
15631563
instructions="You are a helpful assistant with good memory.",
15641564
) as second_agent:
15651565
# Create a thread with the existing ID
@@ -1581,7 +1581,7 @@ async def test_azure_ai_chat_client_agent_code_interpreter():
15811581
"""Test ChatAgent with code interpreter through AzureAIAgentClient."""
15821582

15831583
async with ChatAgent(
1584-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1584+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
15851585
instructions="You are a helpful assistant that can write and execute Python code.",
15861586
tools=[HostedCodeInterpreterTool()],
15871587
) as agent:
@@ -1600,7 +1600,7 @@ async def test_azure_ai_chat_client_agent_code_interpreter():
16001600
async def test_azure_ai_chat_client_agent_file_search():
16011601
"""Test ChatAgent with file search through AzureAIAgentClient."""
16021602

1603-
client = AzureAIAgentClient(async_credential=AzureCliCredential())
1603+
client = AzureAIAgentClient(credential=AzureCliCredential())
16041604
file: FileInfo | None = None
16051605
vector_store: VectorStore | None = None
16061606

@@ -1655,7 +1655,7 @@ async def test_azure_ai_chat_client_agent_hosted_mcp_tool() -> None:
16551655
)
16561656

16571657
async with ChatAgent(
1658-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1658+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
16591659
instructions="You are a helpful assistant that can help with microsoft documentation questions.",
16601660
tools=[mcp_tool],
16611661
) as agent:
@@ -1682,7 +1682,7 @@ async def test_azure_ai_chat_client_agent_hosted_mcp_tool() -> None:
16821682
async def test_azure_ai_chat_client_agent_level_tool_persistence():
16831683
"""Test that agent-level tools persist across multiple runs with AzureAIAgentClient."""
16841684
async with ChatAgent(
1685-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1685+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
16861686
instructions="You are a helpful assistant that uses available tools.",
16871687
tools=[get_weather],
16881688
) as agent:
@@ -1707,7 +1707,7 @@ async def test_azure_ai_chat_client_agent_level_tool_persistence():
17071707
async def test_azure_ai_chat_client_agent_chat_options_run_level() -> None:
17081708
"""Test ChatOptions parameter coverage at run level."""
17091709
async with ChatAgent(
1710-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1710+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
17111711
instructions="You are a helpful assistant.",
17121712
) as agent:
17131713
response = await agent.run(
@@ -1737,7 +1737,7 @@ async def test_azure_ai_chat_client_agent_chat_options_run_level() -> None:
17371737
async def test_azure_ai_chat_client_agent_chat_options_agent_level() -> None:
17381738
"""Test ChatOptions parameter coverage agent level."""
17391739
async with ChatAgent(
1740-
chat_client=AzureAIAgentClient(async_credential=AzureCliCredential()),
1740+
chat_client=AzureAIAgentClient(credential=AzureCliCredential()),
17411741
instructions="You are a helpful assistant.",
17421742
max_tokens=100,
17431743
temperature=0.7,
@@ -1963,7 +1963,7 @@ def test_azure_ai_chat_client_init_with_auto_created_agents_client(
19631963
agent_id="test-agent",
19641964
project_endpoint=azure_ai_unit_test_env["AZURE_AI_PROJECT_ENDPOINT"],
19651965
model_deployment_name=azure_ai_unit_test_env["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
1966-
async_credential=mock_azure_credential,
1966+
credential=mock_azure_credential,
19671967
)
19681968

19691969
# Verify AgentsClient was created with correct parameters

python/packages/azure-ai/tests/test_azure_ai_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_azure_ai_client_init_auto_create_client(
152152
client = AzureAIClient(
153153
project_endpoint=azure_ai_unit_test_env["AZURE_AI_PROJECT_ENDPOINT"],
154154
model_deployment_name=azure_ai_unit_test_env["AZURE_AI_MODEL_DEPLOYMENT_NAME"],
155-
async_credential=mock_azure_credential,
155+
credential=mock_azure_credential,
156156
agent_name="test-agent",
157157
)
158158

@@ -171,11 +171,11 @@ def test_azure_ai_client_init_missing_project_endpoint() -> None:
171171
mock_settings.return_value.model_deployment_name = "test-model"
172172

173173
with pytest.raises(ServiceInitializationError, match="Azure AI project endpoint is required"):
174-
AzureAIClient(async_credential=MagicMock())
174+
AzureAIClient(credential=MagicMock())
175175

176176

177177
def test_azure_ai_client_init_missing_credential(azure_ai_unit_test_env: dict[str, str]) -> None:
178-
"""Test AzureAIClient.__init__ when async_credential is missing and no project_client provided."""
178+
"""Test AzureAIClient.__init__ when credential is missing and no project_client provided."""
179179
with pytest.raises(
180180
ServiceInitializationError, match="Azure credential is required when project_client is not provided"
181181
):
@@ -191,7 +191,7 @@ def test_azure_ai_client_init_validation_error(mock_azure_credential: MagicMock)
191191
mock_settings.side_effect = ValidationError.from_exception_data("test", [])
192192

193193
with pytest.raises(ServiceInitializationError, match="Failed to create Azure AI settings"):
194-
AzureAIClient(async_credential=mock_azure_credential)
194+
AzureAIClient(credential=mock_azure_credential)
195195

196196

197197
async def test_azure_ai_client_get_agent_reference_or_create_existing_version(
@@ -320,7 +320,7 @@ async def test_azure_ai_client_prepare_options_with_application_endpoint(
320320
client = AzureAIClient(
321321
project_endpoint=endpoint,
322322
model_deployment_name="test-model",
323-
async_credential=mock_azure_credential,
323+
credential=mock_azure_credential,
324324
agent_name="test-agent",
325325
agent_version="1",
326326
)

python/packages/lab/gaia/samples/azure_ai_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def create_gaia_agent() -> AsyncIterator[ChatAgent]:
4949
"""
5050
async with (
5151
AzureCliCredential() as credential,
52-
AzureAIAgentClient(async_credential=credential).create_agent(
52+
AzureAIAgentClient(credential=credential).create_agent(
5353
name="GaiaAgent",
5454
instructions="Solve tasks to your best ability. Use Bing Search to find "
5555
"information and Code Interpreter to perform calculations and data analysis.",

0 commit comments

Comments
 (0)