You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, access to this service is granted only by application. You can apply for access to Azure OpenAI by completing the form at <ahref="https://aka.ms/oai/access"target="_blank">https://aka.ms/oai/access</a>. Open an issue on this repo to contact us if you have an issue.
21
21
- <ahref="https://www.python.org/"target="_blank">Python 3.8 or later version</a>
22
-
- The following Python libraries: os, json, openai (Version 1.x is required)
23
-
-[Jupyter Notebooks](https://jupyter.org/)
22
+
- The following Python libraries: os, openai (Version 1.x is required)
23
+
-[Azure CLI](/cli/azure/install-azure-cli) used for passwordless authentication in a local development environment, create the necessary context by signing in with the Azure CLI.
24
24
- Azure OpenAI Assistants are currently available in Sweden Central, East US 2, and Australia East. For more information about model availability in those regions, see the [models guide](../concepts/models.md).
25
25
- We recommend reviewing the [Responsible AI transparency note](/legal/cognitive-services/openai/transparency-note?context=%2Fazure%2Fai-services%2Fopenai%2Fcontext%2Fcontext&tabs=text) and other [Responsible AI resources](/legal/cognitive-services/openai/overview?context=%2Fazure%2Fai-services%2Fopenai%2Fcontext%2Fcontext) to familiarize yourself with the capabilities and limitations of the Azure OpenAI Service.
26
26
- An Azure OpenAI resource with the `gpt-4 (1106-preview)` model deployed was used testing this example.
27
27
28
+
## Passwordless authentication is recommended
29
+
30
+
For passwordless authentication, you need to
31
+
32
+
1. Use the [azure-identity](https://pypi.org/project/azure-identity/) package.
33
+
2. Assign the `Cognitive Services User` role to your user account. This can be done in the Azure portal under **Access control (IAM)** > **Add role assignment**.
34
+
3. Sign in with the Azure CLI such as `az login`.
35
+
28
36
## Set up
29
37
30
-
Install the OpenAI Python client library with:
38
+
1. Install the OpenAI Python client library with:
39
+
40
+
```console
41
+
pip install openai
42
+
```
43
+
44
+
2. For the **recommended** passwordless authentication:
@@ -71,26 +85,29 @@ In our code we are going to specify the following values:
71
85
72
86
An individual assistant can access up to 128 tools including `code interpreter`, as well as any custom tools you create via [functions](../how-to/assistant-functions.md).
73
87
74
-
Create and run an assistant with the following:
88
+
### Create the Python app
89
+
90
+
Sign in to Azure with `az login` then create and run an assistant with the following **recommended** passwordless Python example:
75
91
76
92
```python
77
93
import os
78
-
import time
79
-
import json
94
+
from azure.identity import DefaultAzureCredential, get_bearer_token_provider
In this example we create an assistant with code interpreter enabled. When we ask the assistant a math question it translates the question into python code and executes the code in sandboxed environment in order to determine the answer to the question. The code the model creates and tests to arrive at an answer is:
189
239
190
240
```python
191
-
from sympy import symbols, Eq, solve
192
-
193
-
# Define the variable
194
-
x = symbols('x')
195
-
196
-
# Define the equation
197
-
equation = Eq(3*x +11, 14)
198
-
199
-
# Solve the equation
200
-
solution = solve(equation, x)
201
-
solution
241
+
from sympy import symbols, Eq, solve
242
+
243
+
# Define the variable
244
+
x = symbols('x')
245
+
246
+
# Define the equation
247
+
equation = Eq(3*x +11, 14)
248
+
249
+
# Solve the equation
250
+
solution = solve(equation, x)
251
+
solution
202
252
```
203
253
204
254
It is important to remember that while code interpreter gives the model the capability to respond to more complex queries by converting the questions into code and running that code iteratively in the Python sandbox until it reaches a solution, you still need to validate the response to confirm that the model correctly translated your question into a valid representation in code.
Copy file name to clipboardExpand all lines: articles/ai-services/openai/references/azure-search.md
+17-1Lines changed: 17 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ The configurable options of Azure AI Search when using Azure OpenAI On Your Data
27
27
|--- | --- | --- | --- |
28
28
|`endpoint`| string | True | The absolute endpoint path for the Azure Search resource to use.|
29
29
|`index_name`| string | True | The name of the index to use in the referenced Azure Search resource.|
30
-
|`authentication`| One of [ApiKeyAuthenticationOptions](#api-key-authentication-options), [SystemAssignedManagedIdentityAuthenticationOptions](#system-assigned-managed-identity-authentication-options), [UserAssignedManagedIdentityAuthenticationOptions](#user-assigned-managed-identity-authentication-options)| True | The authentication method to use when accessing the defined data source. |
30
+
|`authentication`| One of [ApiKeyAuthenticationOptions](#api-key-authentication-options), [SystemAssignedManagedIdentityAuthenticationOptions](#system-assigned-managed-identity-authentication-options), [UserAssignedManagedIdentityAuthenticationOptions](#user-assigned-managed-identity-authentication-options), [onYourDataAccessTokenAuthenticationOptions](#access-token-authentication-options)| True | The authentication method to use when accessing the defined data source. |
31
31
|`embedding_dependency`| One of [DeploymentNameVectorizationSource](#deployment-name-vectorization-source), [EndpointVectorizationSource](#endpoint-vectorization-source)| False | The embedding dependency for vector search. Required when `query_type` is `vector`, `vector_simple_hybrid`, or `vector_semantic_hybrid`.|
32
32
|`fields_mapping`|[FieldsMappingOptions](#fields-mapping-options)| False | Customized field mapping behavior to use when interacting with the search index.|
33
33
|`filter`| string | False | Search filter. |
@@ -37,6 +37,10 @@ The configurable options of Azure AI Search when using Azure OpenAI On Your Data
37
37
|`semantic_configuration`| string | False | The semantic configuration for the query. Required when `query_type` is `semantic` or `vector_semantic_hybrid`.|
38
38
|`strictness`| integer | False | The configured strictness of the search relevance filtering. The higher of strictness, the higher of the precision but lower recall of the answer. Default is `3`.|
39
39
|`top_n_documents`| integer | False | The configured top number of documents to feature for the configured query. Default is `5`. |
40
+
|`max_search_queries`| integer | False | The max number of rewritten queries should be send to search provider for one user message. If not specified, the system will decide the number of queries to send. |
41
+
|`allow_partial_result`| integer | False | If specified as true, the system will allow partial search results to be used and the request fails if all the queries fail. If not specified, or specified as false, the request will fail if any search query fails. |
42
+
|`include_contexts`| array | False | The included properties of the output context. If not specified, the default value is `citations` and `intent`. Values can be `citations`,`intent`, `all_retrieved_documents`.|
43
+
40
44
41
45
## API key authentication options
42
46
@@ -64,6 +68,15 @@ The authentication options for Azure OpenAI On Your Data when using a user-assig
64
68
|`managed_identity_resource_id`|string|True|The resource ID of the user-assigned managed identity to use for authentication.|
65
69
|`type`|string|True| Must be `user_assigned_managed_identity`.|
66
70
71
+
## Access token authentication options
72
+
73
+
The authentication options for Azure OpenAI On Your Data when using access token.
74
+
75
+
|Name | Type | Required | Description |
76
+
|--- | --- | --- | --- |
77
+
|`access_token`|string|True|The access token to use for authentication.|
78
+
|`type`| string | True | Must be `access_token`. |
79
+
67
80
## Deployment name vectorization source
68
81
69
82
The details of the vectorization source, used by Azure OpenAI On Your Data when applying vector search. This vectorization source is based on an internal embeddings model deployment name in the same Azure OpenAI resource. This vectorization source enables you to use vector search without Azure OpenAI api-key and without Azure OpenAI public network access.
@@ -72,6 +85,7 @@ The details of the vectorization source, used by Azure OpenAI On Your Data when
72
85
|--- | --- | --- | --- |
73
86
|`deployment_name`|string|True|The embedding model deployment name within the same Azure OpenAI resource. |
74
87
|`type`|string|True| Must be `deployment_name`.|
88
+
|`dimensions`|integer|False| The number of dimensions the embeddings should have. Only supported in `text-embedding-3` and later models. |
75
89
76
90
## Endpoint vectorization source
77
91
@@ -82,6 +96,8 @@ The details of the vectorization source, used by Azure OpenAI On Your Data when
82
96
|`endpoint`|string|True|Specifies the resource endpoint URL from which embeddings should be retrieved. It should be in the format of `https://{YOUR_RESOURCE_NAME}.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME/embeddings`. The api-version query parameter isn't allowed.|
83
97
|`authentication`|[ApiKeyAuthenticationOptions](#api-key-authentication-options)|True | Specifies the authentication options to use when retrieving embeddings from the specified endpoint.|
84
98
|`type`|string|True| Must be `endpoint`.|
99
+
|`dimensions`|integer|False| The number of dimensions the embeddings should have. Only supported in `text-embedding-3` and later models. |
0 commit comments