Skip to content

Commit 7ce6fbe

Browse files
authored
Minor changes to make project_client.assistants.get_client() work
1 parent 5356e66 commit 7ce6fbe

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

Diff for: sdk/ai/azure-ai-projects-onedp/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ project_client = AIProjectClient.from_connection_string(
8484

8585
### Getting an authenticated Assistant client
8686

87-
Below is a code example of how to get an authenticated `AssistantClient` from the `azure-ai-assistants` package.
87+
Below is a code example of how to get an authenticated `AssistantsClient` from the `azure-ai-assistants` package.
8888
Full samples can be found under the `assistants` folder in the [package samples][samples].
8989

90-
<!-- SNIPPET:sample_get_assistant_client.assistants_sample -->
90+
<!-- SNIPPET:sample_get_assistants_client.assistants_sample -->
9191

9292
```python
9393
with project_client.assistants.get_client() as client:
94-
# TODO: Do something with the assistant client...
94+
# TODO: Do something with the assistants client...
9595
pass
9696
```
9797

Diff for: sdk/ai/azure-ai-projects-onedp/azure/ai/projects/onedp/aio/operations/_patch_assistants_async.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ def __init__(self, outer_instance: "azure.ai.projects.onedp.aio.AIProjectClient"
3838
self._outer_instance = outer_instance
3939

4040
@distributed_trace
41-
def get_client(self, **kwargs) -> "AssistantClient": # type: ignore[name-defined]
42-
"""Get an authenticated asynchronous AssistantClient (from the package azure-ai-assistants) to use with
41+
def get_client(self, **kwargs) -> "AssistantsClient": # type: ignore[name-defined]
42+
"""Get an authenticated asynchronous AssistantsClient (from the package azure-ai-assistants) to use with
4343
your AI Foundry Project. Keyword arguments are passed to the constructor of
4444
ChatCompletionsClient.
4545
4646
.. note:: The package `azure-ai-assistants` must be installed prior to calling this method.
4747
4848
:return: An authenticated Assistant Client.
49-
:rtype: ~azure.ai.assistants.AssistantClient
49+
:rtype: ~azure.ai.assistants.AssistantsClient
5050
5151
:raises ~azure.core.exceptions.ModuleNotFoundError: if the `azure-ai-assistants` package
5252
is not installed.
5353
:raises ~azure.core.exceptions.HttpResponseError:
5454
"""
5555

5656
try:
57-
from azure.ai.assistants.aio import AssistantClient
57+
from azure.ai.assistants.aio import AssistantsClient
5858
except ModuleNotFoundError as e:
5959
raise ModuleNotFoundError(
6060
"Azure AI Assistant SDK is not installed. Please install it using 'pip install azure-ai-assistants'"
6161
) from e
6262

63-
client = AssistantClient(
63+
client = AssistantsClient(
6464
endpoint=self._outer_instance._config.endpoint, # pylint: disable=protected-access
6565
credential=self._outer_instance._config.credential, # pylint: disable=protected-access
6666
user_agent=kwargs.pop("user_agent", self._user_agent),

Diff for: sdk/ai/azure-ai-projects-onedp/azure/ai/projects/onedp/aio/operations/_patch_inference_async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ async def get_azure_openai_client(
284284
client = AsyncAzureOpenAI(
285285
# See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider # pylint: disable=line-too-long
286286
azure_ad_token_provider=get_bearer_token_provider(
287-
self._outer_instance._config.credential, # pylint: disable=protected-access
287+
self._outer_instance._config.credential, # pylint: disable=protected-access
288288
"https://cognitiveservices.azure.com/.default", # pylint: disable=protected-access
289289
),
290290
azure_endpoint=azure_endpoint,

Diff for: sdk/ai/azure-ai-projects-onedp/azure/ai/projects/onedp/operations/_patch_assistants.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@ def __init__(self, outer_instance: "azure.ai.projects.onedp.AIProjectClient") ->
3838
self._outer_instance = outer_instance
3939

4040
@distributed_trace
41-
def get_client(self, **kwargs) -> "AssistantClient": # type: ignore[name-defined]
42-
"""Get an authenticated AssistantClient (from the package azure-ai-assistants) to use with
41+
def get_client(self, **kwargs) -> "AssistantsClient": # type: ignore[name-defined]
42+
"""Get an authenticated AssistantsClient (from the package azure-ai-assistants) to use with
4343
your AI Foundry Project. Keyword arguments are passed to the constructor of
4444
ChatCompletionsClient.
4545
4646
.. note:: The package `azure-ai-assistants` must be installed prior to calling this method.
4747
4848
:return: An authenticated Assistant Client.
49-
:rtype: ~azure.ai.assistants.AssistantClient
49+
:rtype: ~azure.ai.assistants.AssistantsClient
5050
5151
:raises ~azure.core.exceptions.ModuleNotFoundError: if the `azure-ai-assistants` package
5252
is not installed.
5353
:raises ~azure.core.exceptions.HttpResponseError:
5454
"""
5555

5656
try:
57-
from azure.ai.assistants import AssistantClient
57+
from azure.ai.assistants import AssistantsClient
5858
except ModuleNotFoundError as e:
5959
raise ModuleNotFoundError(
6060
"Azure AI Assistant SDK is not installed. Please install it using 'pip install azure-ai-assistants'"
6161
) from e
6262

63-
client = AssistantClient(
63+
client = AssistantsClient(
6464
endpoint=self._outer_instance._config.endpoint, # pylint: disable=protected-access
6565
credential=self._outer_instance._config.credential, # pylint: disable=protected-access
6666
user_agent=kwargs.pop("user_agent", self._user_agent),

Diff for: sdk/ai/azure-ai-projects-onedp/azure/ai/projects/onedp/operations/_patch_inference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def get_azure_openai_client(
276276
client = AzureOpenAI(
277277
# See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider # pylint: disable=line-too-long
278278
azure_ad_token_provider=get_bearer_token_provider(
279-
self._outer_instance._config.credential, # pylint: disable=protected-access
279+
self._outer_instance._config.credential, # pylint: disable=protected-access
280280
"https://cognitiveservices.azure.com/.default", # pylint: disable=protected-access
281281
),
282282
azure_endpoint=azure_endpoint,

Diff for: sdk/ai/azure-ai-projects-onedp/samples/assistants/sample_get_assistant_client.py renamed to sdk/ai/azure-ai-projects-onedp/samples/assistants/sample_get_assistants_client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"""
77
DESCRIPTION:
88
Given an AIProjectClient, this sample demonstrates how to get an authenticated
9-
AssistantClient from the azure.ai.assistants package. For more information on
9+
AssistantsClient from the azure.ai.assistants package. For more information on
1010
the azure.ai.assistants package see https://pypi.org/project/azure-ai-assistants/.
1111
1212
USAGE:
13-
python sample_get_assistant_client.py
13+
python sample_get_assistants_client.py
1414
1515
Before running the sample:
1616
@@ -34,6 +34,6 @@
3434

3535
# [START assistants_sample]
3636
with project_client.assistants.get_client() as client:
37-
# TODO: Do something with the assistant client...
37+
# TODO: Do something with the assistants client...
3838
pass
3939
# [END sample]

Diff for: sdk/ai/azure-ai-projects-onedp/samples/assistants/sample_get_assistant_client_async.py renamed to sdk/ai/azure-ai-projects-onedp/samples/assistants/sample_get_assistants_client_async.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"""
77
DESCRIPTION:
88
Given an AIProjectClient, this sample demonstrates how to get an authenticated
9-
asynchronous AssistantClient from the azure.ai.assistants package. For more information on
9+
asynchronous AssistantsClient from the azure.ai.assistants package. For more information on
1010
the azure.ai.assistants package see https://pypi.org/project/azure-ai-assistants/.
1111
1212
USAGE:
13-
python sample_get_assistant_client_async.py
13+
python sample_get_assistants_client_async.py
1414
1515
Before running the sample:
1616
@@ -27,7 +27,7 @@
2727
from azure.ai.projects.onedp.aio import AIProjectClient
2828

2929

30-
async def sample_get_assistant_client_async():
30+
async def sample_get_assistants_client_async():
3131

3232
endpoint = os.environ["PROJECT_ENDPOINT"]
3333

@@ -36,13 +36,13 @@ async def sample_get_assistant_client_async():
3636
credential=DefaultAzureCredential(),
3737
) as project_client:
3838

39-
with project_client.assistants.get_client() as client:
39+
async with project_client.assistants.get_client() as client:
4040
# TODO: Do something with the assistant client...
4141
pass
4242

4343

4444
async def main():
45-
await sample_get_assistant_client_async()
45+
await sample_get_assistants_client_async()
4646

4747

4848
if __name__ == "__main__":

Diff for: sdk/ai/azure-ai-projects-onedp/samples/inference/sample_chat_completions_with_azure_ai_inference_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444
)
4545

4646
print(response.choices[0].message.content)
47-
# [END inference_sample]
47+
# [END inference_sample]

0 commit comments

Comments
 (0)