Skip to content

Commit 62ccd06

Browse files
authored
Minor updates to package README.md. Remove /en-us/ from links shown on samples and in source code (Azure#38554)
1 parent b63200a commit 62ccd06

14 files changed

+94
-59
lines changed

.vscode/cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,8 @@
13301330
"aiservices",
13311331
"OTEL",
13321332
"GENAI",
1333-
"fspath"
1333+
"fspath",
1334+
"azureopenai"
13341335
]
13351336
},
13361337
{

sdk/ai/azure-ai-projects/README.md

Lines changed: 75 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,66 @@ Use the AI Projects client library (in preview) to:
55

66
* **Enumerate connections** in your Azure AI Studio project and get connection properties.
77
For example, get the inference endpoint URL and credentials associated with your Azure OpenAI connection.
8-
* **Get an already-authenticated Inference client** for the default Azure OpenAI or AI Services connections in your Azure AI Studio project. Supports the AzureOpenAI client from the `openai` package, or clients from the `azure-ai-inference` package.
8+
* **Get an authenticated Inference client** to do chat completions, for the default Azure OpenAI or AI Services connections in your Azure AI Studio project. Supports the AzureOpenAI client from the `openai` package, or clients from the `azure-ai-inference` package.
99
* **Develop Agents using the Azure AI Agent Service**, leveraging an extensive ecosystem of models, tools, and capabilities from OpenAI, Microsoft, and other LLM providers. The Azure AI Agent Service enables the building of Agents for a wide range of generative AI use cases. The package is currently in private preview.
10-
* **Run Evaluation tools** to assess the performance of generative AI applications using various evaluators and metrics. It includes built-in evaluators for quality, risk, and safety, and allows custom evaluators for specific needs.
10+
* **Run Evaluations** to assess the performance of generative AI applications using various evaluators and metrics. It includes built-in evaluators for quality, risk, and safety, and allows custom evaluators for specific needs.
1111
* **Enable OpenTelemetry tracing**.
1212

1313
[Product documentation](https://aka.ms/azsdk/azure-ai-projects/product-doc)
1414
| [Samples][samples]
1515
| [API reference documentation](https://aka.ms/azsdk/azure-ai-projects/python/reference)
1616
| [Package (PyPI)](https://aka.ms/azsdk/azure-ai-projects/python/package)
1717
| [SDK source code](https://aka.ms/azsdk/azure-ai-projects/python/code)
18+
| [AI Starter Template](https://aka.ms/azsdk/azure-ai-projects/python/ai-starter-template)
19+
20+
## Table of contents
21+
22+
- [Getting started](#getting-started)
23+
- [Prerequisite](#prerequisite)
24+
- [Install the package](#install-the-package)
25+
- [Key concepts](#key-concepts)
26+
- [Create and authenticate the client](#create-and-authenticate-the-client)
27+
- [Examples](#examples)
28+
- [Enumerate connections](#enumerate-connections)
29+
- [Get properties of all connections](#get-properties-of-all-connections)
30+
- [Get properties of all connections of a particular type](#get-properties-of-all-connections-of-a-particular-type)
31+
- [Get properties of a default connection](#get-properties-of-a-default-connection)
32+
- [Get properties of a connection by its connection name](#get-properties-of-a-connection-by-its-connection-name)
33+
- [Get an authenticated ChatCompletionsClient](#get-an-authenticated-chatcompletionsclient)
34+
- [Get an authenticated AzureOpenAI client](#get-an-authenticated-azureopenai-client)
35+
- [Agents (Private Preview)](#agents-private-preview)
36+
- [Create an Agent](#create-agent) with:
37+
- [File Search](#create-agent-with-file-search)
38+
- [Code interpreter](#create-agent-with-code-interpreter)
39+
- [Bing grounding](#create-agent-with-bing-grounding)
40+
- [Azure AI Search](#create-agent-with-azure-ai-search)
41+
- [Function call](#create-agent-with-function-call)
42+
- [Create thread](#create-thread) with
43+
- [Tool resource](#create-thread-with-tool-resource)
44+
- [Create message](#create-message) with:
45+
- [File search attachment](#create-message-with-file-search-attachment)
46+
- [Code interpreter attachment](#create-message-with-code-interpreter-attachment)
47+
- [Execute Run, Run_and_Process, or Stream](#create-run-run_and_process-or-stream)
48+
- [Retrieve message](#retrieve-message)
49+
- [Retrieve file](#retrieve-file)
50+
- [Tear down by deleting resource](#teardown)
51+
- [Tracing](#tracing)
52+
- [Evaluation](#evaluation)
53+
- [Evaluator](#evaluator)
54+
- [Run Evaluation in the cloud](#run-evaluation-in-the-cloud)
55+
- [Evaluators](#evaluators)
56+
- [Data to be evaluated](#data-to-be-evaluated)
57+
- [[Optional] Azure OpenAI Model](#optional-azure-openai-model)
58+
- [Example Remote Evaluation](#example-remote-evaluation)
59+
- [Tracing](#tracing)
60+
- [Installation](#installation)
61+
- [Tracing example](#tracing-example)
62+
- [Troubleshooting](#troubleshooting)
63+
- [Exceptions](#exceptions)
64+
- [Logging](#logging)
65+
- [Reporting issues](#reporting-issues)
66+
- [Next steps](#next-steps)
67+
- [Contributing](#contributing)
1868

1969
## Getting started
2070

@@ -25,8 +75,7 @@ For example, get the inference endpoint URL and credentials associated with your
2575
- A [project in Azure AI Studio](https://learn.microsoft.com/azure/ai-studio/how-to/create-projects?tabs=ai-studio).
2676
- The project connection string. It can be found in your Azure AI Studio project overview page, under "Project details". Below we will assume the environment variable `PROJECT_CONNECTION_STRING` was defined to hold this value.
2777
- Entra ID is needed to authenticate the client. Your application needs an object that implements the [TokenCredential](https://learn.microsoft.com/python/api/azure-core/azure.core.credentials.tokencredential) interface. Code samples here use [DefaultAzureCredential](https://learn.microsoft.com/python/api/azure-identity/azure.identity.defaultazurecredential). To get that working, you will need:
28-
* The role `Azure AI Developer` assigned to you. Role assigned can be done via the "Access Control (IAM)" tab of your Azure AI Project resource in the Azure portal.
29-
* The token must have the scope `https://management.azure.com/.default` or `https://ml.azure.com/.default`, depending on the set of client operation you will execute.
78+
* The `Contributor` role. Role assigned can be done via the "Access Control (IAM)" tab of your Azure AI Project resource in the Azure portal.
3079
* [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed.
3180
* You are logged into your Azure account by running `az login`.
3281
* Note that if you have multiple Azure subscriptions, the subscription that contains your Azure AI Project resource must be your default subscription. Run `az account list --output table` to list all your subscription and see which one is the default. Run `az account set --subscription "Your Subscription ID or Name"` to change your default subscription.
@@ -78,9 +127,9 @@ project_client = AIProjectClient.from_connection_string(
78127

79128
### Enumerate connections
80129

81-
You Azure AI Studio project has a "Management center". When you enter it, you will see a tab named "Connected resources" under your project. The `.connections` operations on the client allow you to enumerate the connections and get connection properties. Connection properties include the resource URL and authentication credentials, among other things.
130+
Your Azure AI Studio project has a "Management center". When you enter it, you will see a tab named "Connected resources" under your project. The `.connections` operations on the client allow you to enumerate the connections and get connection properties. Connection properties include the resource URL and authentication credentials, among other things.
82131

83-
Below are code examples of some simple connection operations. Additional samples can be found under the "connetions" folder in the [package samples][samples].
132+
Below are code examples of the connection operations. Full samples can be found under the "connetions" folder in the [package samples][samples].
84133

85134
#### Get properties of all connections
86135

@@ -113,7 +162,7 @@ with its authentication credentials:
113162
```python
114163
connection = project_client.connections.get_default(
115164
connection_type=ConnectionType.AZURE_OPEN_AI,
116-
include_credentials=True, # Optional. Defaults to "False"
165+
include_credentials=True, # Optional. Defaults to "False".
117166
)
118167
print(connection)
119168
```
@@ -123,18 +172,21 @@ will be populated. Otherwise both will be `None`.
123172

124173
#### Get properties of a connection by its connection name
125174

126-
To get the connection properties of a connection with name `connection_name`:
175+
To get the connection properties of a connection named `connection_name`:
127176

128177
```python
129178
connection = project_client.connections.get(
130-
connection_name=connection_name, include_credentials=True # Optional. Defaults to "False"
179+
connection_name=connection_name,
180+
include_credentials=True # Optional. Defaults to "False"
131181
)
132182
print(connection)
133183
```
134184

135185
### Get an authenticated ChatCompletionsClient
136186

137-
Your Azure AI Studio project may have one or more AI models deployed that support chat completions. These could be OpenAI models, Microsoft models, or models from other providers. Use the code below to get an already authenticated [ChatCompletionsClient](https://learn.microsoft.com/python/api/azure-ai-inference/azure.ai.inference.chatcompletionsclient?view=azure-python-preview) from the [azure-ai-inference](https://pypi.org/project/azure-ai-inference/) package, and execute a chat completions call. First, install the package:
187+
Your Azure AI Studio project may have one or more AI models deployed that support chat completions. These could be OpenAI models, Microsoft models, or models from other providers. Use the code below to get an already authenticated [ChatCompletionsClient](https://learn.microsoft.com/python/api/azure-ai-inference/azure.ai.inference.chatcompletionsclient?view=azure-python-preview) from the [azure-ai-inference](https://pypi.org/project/azure-ai-inference/) package, and execute a chat completions call.
188+
189+
First, install the package:
138190

139191
```bash
140192
pip install azure-ai-inference
@@ -157,13 +209,15 @@ See the "inference" folder in the [package samples][samples] for additional samp
157209

158210
### Get an authenticated AzureOpenAI client
159211

160-
Your Azure AI Studio project may have one or more OpenAI models deployed that support chat completions. Use the code below to get an already authenticated [AzureOpenAI](https://github.com/openai/openai-python?tab=readme-ov-file#microsoft-azure-openai) from the [openai](https://pypi.org/project/openai/) package, and execute a chat completions call. First, install the package:
212+
Your Azure AI Studio project may have one or more OpenAI models deployed that support chat completions. Use the code below to get an already authenticated [AzureOpenAI](https://github.com/openai/openai-python?tab=readme-ov-file#microsoft-azure-openai) from the [openai](https://pypi.org/project/openai/) package, and execute a chat completions call.
213+
214+
First, install the package:
161215

162216
```bash
163217
pip install openai
164218
```
165219

166-
Then run this code (replace "gpt-4o" with your model deployment name):
220+
Then run the code below. Replace `gpt-4o` with your model deployment name, and update the `api_version` value with one found in the "Data plane - inference" row [in this table](https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs).
167221

168222
```python
169223
aoai_client = project_client.inference.get_azure_openai_client(api_version="2024-06-01")
@@ -189,23 +243,6 @@ Agents in the Azure AI Projects client library are designed to facilitate variou
189243

190244
Agents are actively being developed. A sign-up form for private preview is coming soon.
191245

192-
- <a href='#create-agent'>Create an Agent</a> with:
193-
- <a href='#create-agent-with-file-search'>File Search</a>
194-
- <a href='#create-agent-with-code-interpreter'>Code interpreter</a>
195-
- <a href='#create-agent-with-bing-grounding'>Bing grounding</a>
196-
- <a href='#create-agent-with-azure-ai-search'>Azure AI Search</a>
197-
- <a href='#create-agent-with-function-call'>Function call</a>
198-
- <a href='#create-thread'>Create thread</a> with
199-
- <a href='#create-thread-with-tool-resource'>Tool resource</a>
200-
- <a href='#create-message'>Create message</a> with:
201-
- <a href='#create-message-with-file-search-attachment'>File search attachment</a>
202-
- <a href='#create-message-with-code-interpreter-attachment'>Code interpreter attachment</a>
203-
- <a href='#create-run-run_and_process-or-stream'>Execute Run, Run_and_Process, or Stream</a>
204-
- <a href='#retrieve-message'>Retrieve message</a>
205-
- <a href='#retrieve-file'>Retrieve file</a>
206-
- <a href='#teardown'>Tear down by deleting resource</a>
207-
- <a href='#tracing'>Tracing</a>
208-
209246
#### Create Agent
210247

211248
Here is an example of how to create an Agent:
@@ -730,19 +767,19 @@ Evaluators are made available via [azure-ai-evaluation][azure_ai_evaluation] SDK
730767

731768
More details on built-in and custom evaluators can be found [here][evaluators].
732769

733-
#### Run Evaluation in cloud:
770+
#### Run Evaluation in the cloud
734771

735-
To run evaluation in cloud the following are needed:
772+
To run evaluation in the cloud the following are needed:
736773

737774
- Evaluators
738775
- Data to be evaluated
739776
- [Optional] Azure Open AI model.
740777

741778
##### Evaluators
742779

743-
For running evaluator in cloud, evaluator `ID` is needed. To get it via code you use [azure-ai-evaluation][azure_ai_evaluation]
780+
For running evaluator in the cloud, evaluator `ID` is needed. To get it via code you use [azure-ai-evaluation][azure_ai_evaluation]
744781

745-
```
782+
```python
746783
# pip install azure-ai-evaluation
747784

748785
from azure.ai.evaluation import RelevanceEvaluator
@@ -831,11 +868,11 @@ print("----------------------------------------------------------------")
831868

832869
NOTE: For running evaluators locally refer to [Evaluate with the Azure AI Evaluation SDK][evaluators].
833870

834-
#### Tracing
871+
### Tracing
835872

836873
You can add an Application Insights Azure resource to your Azure AI Studio project. See the Tracing tab in your studio. If one was enabled, you can get the Application Insights connection string, configure your Agents, and observe the full execution path through Azure Monitor. Typically, you might want to start tracing before you create an Agent.
837874

838-
##### Installation
875+
#### Installation
839876

840877
Make sure to install OpenTelemetry and the Azure SDK tracing plugin via
841878

@@ -852,7 +889,7 @@ To connect to Aspire Dashboard or another OpenTelemetry compatible backend, inst
852889
pip install opentelemetry-exporter-otlp
853890
```
854891

855-
##### Tracing example
892+
#### Tracing example
856893

857894
Here is a code sample to be included above `create_agent`:
858895

@@ -960,6 +997,8 @@ To report issues with the client library, or request additional features, please
960997

961998
Have a look at the [Samples](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/ai/azure-ai-projects/samples) folder, containing fully runnable Python code for synchronous and asynchronous clients.
962999

1000+
Explore the [AI Starter Template](https://aka.ms/azsdk/azure-ai-projects/python/ai-starter-template). This template creates an Azure AI Studio hub, project and connected resources including Azure OpenAI Service, AI Search and more. It also deploys a simple chat application to Azure Container Apps.
1001+
9631002
## Contributing
9641003

9651004
This project welcomes contributions and suggestions. Most contributions require

sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ async def get_azure_openai_client(self, *, api_version: Optional[str] = None, **
222222
223223
:keyword api_version: The Azure OpenAI api-version to use when creating the client. Optional.
224224
See "Data plane - Inference" row in the table at
225-
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs. If this keyword
225+
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs. If this keyword
226226
is not specified, you must set the environment variable `OPENAI_API_VERSION` instead.
227227
:paramtype api_version: str
228228
:return: An authenticated AsyncAzureOpenAI client

sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def get_azure_openai_client(self, *, api_version: Optional[str] = None, **kwargs
211211
212212
:keyword api_version: The Azure OpenAI api-version to use when creating the client. Optional.
213213
See "Data plane - Inference" row in the table at
214-
https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs. If this keyword
214+
https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs. If this keyword
215215
is not specified, you must set the environment variable `OPENAI_API_VERSION` instead.
216216
:paramtype api_version: str
217217
:return: An authenticated AzureOpenAI client
@@ -253,7 +253,7 @@ def get_azure_openai_client(self, *, api_version: Optional[str] = None, **kwargs
253253
auth = "Creating AzureOpenAI using SAS authentication"
254254
logger.debug("[InferenceOperations.get_azure_openai_client] %s", auth)
255255
client = AzureOpenAI(
256-
# See https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider # pylint: disable=line-too-long
256+
# 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
257257
azure_ad_token_provider=get_bearer_token_provider(
258258
connection.token_credential, "https://cognitiveservices.azure.com/.default"
259259
),

sdk/ai/azure-ai-projects/azure_ai_projects_tests.env

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
# but do not commit these changes to the repository.
66
#
77

8-
# The default here should be to run tests from recordings:
9-
AZURE_TEST_RUN_LIVE=false
10-
AZURE_SKIP_LIVE_RECORDING=true
11-
PROXY_URL=http://localhost:5000
12-
138
########################################################################################################################
149
# Connection tests
1510
#
@@ -35,7 +30,7 @@ AZURE_AI_PROJECTS_CONNECTIONS_TESTS_AISERVICES_CONNECTION_NAME=
3530
# - A default AIServices resource with at least one chat-completions model deployed (from OpenAI or non-OpenAI)
3631
# - A default Azure OpenAI resource connected with at least one chat-completions OpenAI model deployed
3732
# Populate the Azure OpenAI api-version and model deployment names below.
38-
# Note: See Azure OpenAI api-versions here: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
33+
# Note: See Azure OpenAI api-versions here: https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
3934
#
4035
AZURE_AI_PROJECTS_INFERENCE_TESTS_PROJECT_CONNECTION_STRING=
4136
AZURE_AI_PROJECTS_INFERENCE_TESTS_AOAI_API_VERSION=

sdk/ai/azure-ai-projects/samples/connections/async_samples/sample_connections_async.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ async def sample_connections_async() -> None:
8686
aoai_client = AsyncAzureOpenAI(
8787
api_key=connection.key,
8888
azure_endpoint=connection.endpoint_url,
89-
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
89+
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
9090
)
9191
elif connection.authentication_type == AuthenticationType.ENTRA_ID:
9292
print("====> Creating AzureOpenAI client using Entra ID authentication")
9393
from azure.identity.aio import get_bearer_token_provider
9494

9595
aoai_client = AsyncAzureOpenAI(
96-
# See https://learn.microsoft.com/en-us/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider
96+
# See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider
9797
azure_ad_token_provider=get_bearer_token_provider(
9898
cast(AsyncTokenCredential, connection.token_credential),
9999
"https://cognitiveservices.azure.com/.default",
100100
),
101101
azure_endpoint=connection.endpoint_url,
102-
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#api-specs
102+
api_version="2024-06-01", # See "Data plane - inference" row in table https://learn.microsoft.com/azure/ai-services/openai/reference#api-specs
103103
)
104104
else:
105105
raise ValueError(f"Authentication type {connection.authentication_type} not supported.")

0 commit comments

Comments
 (0)