Skip to content

Commit 1f3b1bb

Browse files
committed
removed k, not used
1 parent a96a254 commit 1f3b1bb

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 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,8 +263,7 @@ 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"])

0 commit comments

Comments
 (0)