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
Copy file name to clipboardExpand all lines: articles/search/search-get-started-rag.md
+26-19Lines changed: 26 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ This quickstart shows you how to send queries to a Large Language Model (LLM) fo
17
17
18
18
- An Azure subscription. [Create one for free](https://azure.microsoft.com/free/).
19
19
20
-
-[Azure AI Search](search-create-service-portal.md), on any tier. Region must be the same one used for Azure OpenAI.
20
+
-[Azure AI Search](search-create-service-portal.md), Basic tier or higher so that you can [enable semantic ranking](semantic-how-to-enable-disable.md). Region must be the same one used for Azure OpenAI.
21
21
22
22
-[Azure OpenAI](https://aka.ms/oai/access) resource with a deployment of `gpt-35-turbo`, `gpt-4`, or equivalent model, in the same region as Azure AI Search.
23
23
@@ -33,24 +33,30 @@ You can also start a new file on your local system and create requests manually
33
33
34
34
Requests to the search endpoint must be authenticated and authorized. You can use API keys or roles for this task. Keys are easier to start with, but roles are more secure. This quickstart assumes roles.
35
35
36
-
1. Configure Azure OpenAI to use a system-assigned managed identity.
37
-
1. In the Azure portal, find your Azure OpenAI resource.
38
-
1. On the left menu, select **Resource management** > **Identity**.
39
-
1. On the System assigned tab, set status to **On**.
36
+
1. Configure Azure OpenAI to use a system-assigned managed identity:
37
+
1. In the Azure portal, find your Azure OpenAI resource.
38
+
1. On the left menu, select **Resource management** > **Identity**.
39
+
1. On the System assigned tab, set status to **On**.
40
40
41
-
1. Grant Azure OpenAI permission to access Azure AI Search:
42
-
1. In the Azure portal, find your Azure AI Search service.
43
-
1. On the left menu, select **Access control (IAM)**.
44
-
1. Add the following role assignments for Azure OpenAI managed identity: Search Index Data Reader
45
-
You only need data reader for this quickstart because this scenario is limited to query operations.
41
+
1. Configure Azure AI Search for role-based access and assign roles:
42
+
1. In the Azure portal, find your Azure AI Search service.
43
+
1. On the left menu, select **Settings** > **Keys**, and then select either **Role-based access control** or **Both**.
44
+
1. On the left menu, select **Access control (IAM)**.
45
+
1. Add the following role assignments for the Azure OpenAI managed identity: **Search Index Data Reader**
46
+
47
+
You only need data reader for this quickstart because this scenario is limited to query operations.
48
+
49
+
1. Assign yourself to the **Cognitive Services OpenAI User** role on Azure OpenAI. This is the only role you need for query workloads.
50
+
51
+
It can take several minutes for permissions to take effect.
46
52
47
53
## Create an index
48
54
49
55
We recommend the hotels-sample-index, which can be created in minutes and runs on any search service tier. This index is created using built-in sample data.
50
56
51
57
1. In the Azure portal, find your search service.
52
58
53
-
1. On the **Overview** home page, select **Import data** at the top to start the wizard.
59
+
1. On the **Overview** home page, select [**Import data**](search-get-started-portal.md) to start the wizard.
54
60
55
61
1. On the **Connect to your data** page, select **Samples** from the dropdown list.
56
62
@@ -119,13 +125,11 @@ We recommend the hotels-sample-index, which can be created in minutes and runs o
119
125
120
126
1. [Find your search service](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.Search%2FsearchServices).
121
127
122
-
1. On the **Overview** home page, copy the URL. An example endpoint might look like `https://mydemo.search.windows.net`.
123
-
124
-
:::image type="content" source="media/search-get-started-rest/get-endpoint.png" lightbox="media/search-get-started-rest/get-endpoint.png" alt-text="Screenshot of the URL property on the overview page.":::
128
+
1. On the **Overview** home page, copy the URL. An example endpoint might look like `https://example.search.windows.net`.
125
129
126
130
1. [Find your Azure OpenAI service](https://portal.azure.com/#blade/HubsExtension/BrowseResourceBlade/resourceType/Microsoft.CognitiveServices%2Faccounts).
127
131
128
-
1. On the **Overview** home page, select the link to view the endpoints. Copy the URL.
132
+
1. On the **Overview** home page, select the link to view the endpoints. Copy the URL. An example endpoint might look like `https://example.openai.azure.com/`.
129
133
130
134
## Set up the query and chat thread
131
135
@@ -139,15 +143,15 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
139
143
! pip install openai --quiet
140
144
```
141
145
142
-
1. Set the following variables, substituting placeholders with valid values.
146
+
1. Set the following variables, substituting placeholders with the endpoints you collected in the previous step.
143
147
144
148
```python
145
149
AZURE_SEARCH_SERVICE: str="PUT YOUR SEARCH SERVICE ENDPOINT HERE"
146
150
AZURE_OPENAI_ACCOUNT: str="PUT YOUR AZURE OPENAI ENDPOINT HERE"
147
151
AZURE_DEPLOYMENT_MODEL: str="gpt-35-turbo"
148
152
```
149
153
150
-
1. Specify query parameters. The query is a keyword search using semantic ranking. The search engine returns up to 50 matches, but the model returns just the top 5 in the response.
154
+
1. Specify query parameters. The query is a keyword search using semantic ranking. The search engine returns up to 50 matches, but the model returns just the top 5 in the response. If you can't enable semantic ranking on your search service, set the value to false.
151
155
152
156
```python
153
157
# Set query parameters for grounding the conversation on your search index
@@ -157,7 +161,7 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
157
161
sources_to_include=5
158
162
```
159
163
160
-
1. Set up clients, functions, prompts, andchat thread. The function retrieves selected fields from the search index.
164
+
1. Set up clients, a search functions prompts, anda chat. The function retrieves selected fields from the search index.
161
165
162
166
```python
163
167
# Set up the query for generating responses
@@ -202,6 +206,7 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
202
206
203
207
return [ document asyncfor document in response ]
204
208
209
+
# This prompt provides instructions to the model
205
210
GROUNDED_PROMPT="""
206
211
You are a friendly assistant that recommends hotels based on activities and amenities.
207
212
Answer the query using only the sources provided below in a friendly and concise bulleted manner.
@@ -211,6 +216,8 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
211
216
Query: {query}
212
217
Sources:\n{sources}
213
218
"""
219
+
220
+
# This class instantiates the chat
214
221
classChatThread:
215
222
def__init__(self):
216
223
self.messages = []
@@ -248,7 +255,7 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
0 commit comments