Skip to content

Commit 3483ccc

Browse files
Merge pull request #281567 from HeidiSteen/heidist-qs-rag
quickstart -- removed k, not used
2 parents 87de02a + e594809 commit 3483ccc

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

articles/search/search-get-started-rag.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,24 @@ Requests to the search endpoint must be authenticated and authorized. You can us
4141

4242
1. On the System assigned tab, set status to **On**.
4343

44-
1. Configure Azure AI Search for role-based access and assign roles:
44+
1. Configure Azure AI Search for role-based access:
4545

4646
1. In the Azure portal, find your Azure AI Search service.
4747

4848
1. On the left menu, select **Settings** > **Keys**, and then select either **Role-based access control** or **Both**.
4949

5050
1. On the left menu, select **Access control (IAM)**.
5151

52-
1. Add the following role assignments for the Azure OpenAI managed identity: **Search Index Data Reader**, **Search Service Contributor**.
52+
1. Assign roles:
5353

54-
1. Assign yourself to the **Cognitive Services OpenAI User** role on Azure OpenAI. This is the only role you need for query workloads.
54+
1. Add the following role assignments for the Azure OpenAI managed identity:
55+
56+
- **Search Index Data Reader**
57+
- **Search Service Contributor**
58+
59+
1. Assign yourself to a role on Azure OpenAI. In this quickstart, the requests to Azure OpenAI are sent on your behalf:
60+
61+
- **Cognitive Services OpenAI User**
5562

5663
It can take several minutes for permissions to take effect.
5764

@@ -140,11 +147,10 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
140147
AZURE_DEPLOYMENT_MODEL: str = "gpt-35-turbo"
141148
```
142149

143-
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.
150+
1. Run the following code to set query parameters. The query is a keyword search using semantic ranking. In a keyword search, the search engine returns up to 50 matches, but only the top 5 are provided to the model. If you can't enable semantic ranking on your search service, set the value to false.
144151

145152
```python
146153
# Set query parameters for grounding the conversation on your search index
147-
k=50
148154
search_type="text"
149155
use_semantic_reranker=True
150156
sources_to_include=5
@@ -157,7 +163,6 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
157163
from azure.core.credentials_async import AsyncTokenCredential
158164
from azure.identity.aio import get_bearer_token_provider
159165
from azure.search.documents.aio import SearchClient
160-
from azure.search.documents.models import VectorizableTextQuery, HybridSearch
161166
from openai import AsyncAzureOpenAI
162167
from enum import Enum
163168
from typing import List, Optional
@@ -184,7 +189,7 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
184189
HYBRID = "hybrid"
185190

186191
# This function retrieves the selected fields from the search index
187-
async def get_sources(search_client: SearchClient, query: str, search_type: SearchType, use_semantic_reranker: bool = True, sources_to_include: int = 5, k: int = 50) -> List[str]:
192+
async def get_sources(search_client: SearchClient, query: str, search_type: SearchType, use_semantic_reranker: bool = True, sources_to_include: int = 5) -> List[str]:
188193
search_type == SearchType.TEXT,
189194
response = await search_client.search(
190195
search_text=query,
@@ -218,8 +223,8 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
218223
"content": message
219224
})
220225

221-
async def append_grounded_message(self, search_client: SearchClient, query: str, search_type: SearchType, use_semantic_reranker: bool = True, sources_to_include: int = 5, k: int = 50):
222-
sources = await get_sources(search_client, query, search_type, use_semantic_reranker, sources_to_include, k)
226+
async def append_grounded_message(self, search_client: SearchClient, query: str, search_type: SearchType, use_semantic_reranker: bool = True, sources_to_include: int = 5):
227+
sources = await get_sources(search_client, query, search_type, use_semantic_reranker, sources_to_include)
223228
sources_formatted = "\n".join([f'{document["HotelName"]}:{document["Description"]}:{document["Tags"]}' for document in sources])
224229
self.append_message(role="user", message=GROUNDED_PROMPT.format(query=query, sources=sources_formatted))
225230
self.search_results.append(
@@ -258,27 +263,26 @@ This section uses Visual Studio Code and Python to call the chat APIs on Azure O
258263
query="Can you recommend a few hotels near the ocean with beach access and good views",
259264
search_type=SearchType(search_type),
260265
use_semantic_reranker=use_semantic_reranker,
261-
sources_to_include=sources_to_include,
262-
k=k)
266+
sources_to_include=sources_to_include)
263267
await chat_thread.get_openai_response(openai_client=openai_client, model=chat_deployment)
264268

265269
print(chat_thread.get_last_message()["content"])
266270
```
267271

268-
Output is from Azure OpenAI, and it consists of recommendations for several hotels. Here's an example of what the output might look like:
269-
270-
```
271-
Based on your criteria, we recommend the following hotels:
272-
273-
- Contoso Ocean Motel: located right on the beach and has private balconies with ocean views. They also have indoor and outdoor pools. It's located on the boardwalk near shops and art entertainment.
274-
- Northwind Plaza & Suites: offers ocean views, free Wi-Fi, full kitchen, and a free breakfast buffet. Although not directly on the beach, this hotel has great views and is near the aquarium. They also have a pool.
272+
Output is from Azure OpenAI, and it consists of recommendations for several hotels. Here's an example of what the output might look like:
275273

276-
Several other hotels have views and water features, but do not offer beach access or views of the ocean.
277-
```
274+
```
275+
Based on your criteria, we recommend the following hotels:
276+
277+
- Contoso Ocean Motel: located right on the beach and has private balconies with ocean views. They also have indoor and outdoor pools. It's located on the boardwalk near shops and art entertainment.
278+
- Northwind Plaza & Suites: offers ocean views, free Wi-Fi, full kitchen, and a free breakfast buffet. Although not directly on the beach, this hotel has great views and is near the aquarium. They also have a pool.
279+
280+
Several other hotels have views and water features, but do not offer beach access or views of the ocean.
281+
```
278282

279-
To experiment further, change the query and rerun the last step to better understand how the model works with your data.
283+
To experiment further, change the query and rerun the last step to better understand how the model works with your data.
280284

281-
You can also modify the prompt to change the tone or structure of the output.
285+
You can also modify the prompt to change the tone or structure of the output.
282286

283287
## Clean up
284288

0 commit comments

Comments
 (0)