Skip to content

Commit 46740e3

Browse files
committed
Removed unnecessary code from quickstart-rag
1 parent 371da4b commit 46740e3

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Quickstart-RAG/Quickstart-rag.ipynb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
" }]},\n",
4949
" ```\n",
5050
"\n",
51-
"- On Azure AI Search, create a role assignment for the Azure OpenAI managed identity. Required roles: Search Index Data Reader, Search Service Contributor.\n",
51+
"- On Azure AI Search, create a role assignment for the Azure OpenAI managed identity. Required roles: **Search Index Data Reader**, **Search Service Contributor**.\n",
5252
"\n",
53-
"- On Azure OpenAI, create a role assigmnet for the user running the code: Required role: Cognitive Services OpenAI User."
53+
"- On Azure OpenAI, create a role assigment for the user running the code: Required role: **Cognitive Services OpenAI User**."
5454
]
5555
},
5656
{
@@ -84,7 +84,6 @@
8484
"outputs": [],
8585
"source": [
8686
"# Set query parameters for grounding the conversation on your search index\n",
87-
"k=50\n",
8887
"search_type=\"text\"\n",
8988
"use_semantic_reranker=True\n",
9089
"sources_to_include=5"
@@ -100,12 +99,10 @@
10099
"from azure.core.credentials_async import AsyncTokenCredential\n",
101100
"from azure.identity.aio import get_bearer_token_provider\n",
102101
"from azure.search.documents.aio import SearchClient\n",
103-
"from azure.search.documents.models import VectorizableTextQuery, HybridSearch\n",
104102
"from openai import AsyncAzureOpenAI\n",
105103
"from enum import Enum\n",
106104
"from typing import List, Optional\n",
107105
"\n",
108-
"\n",
109106
"def create_openai_client(credential: AsyncTokenCredential) -> AsyncAzureOpenAI:\n",
110107
" token_provider = get_bearer_token_provider(credential, \"https://cognitiveservices.azure.com/.default\")\n",
111108
" return AsyncAzureOpenAI(\n",
@@ -128,7 +125,7 @@
128125
" HYBRID = \"hybrid\"\n",
129126
"\n",
130127
"# This function retrieves the sselected fields from the search index\n",
131-
"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]:\n",
128+
"async def get_sources(search_client: SearchClient, query: str, search_type: SearchType, use_semantic_reranker: bool = True, sources_to_include: int = 5) -> List[str]:\n",
132129
" search_type == SearchType.TEXT,\n",
133130
" response = await search_client.search(\n",
134131
" search_text=query,\n",
@@ -159,8 +156,8 @@
159156
" \"content\": message\n",
160157
" })\n",
161158
"\n",
162-
" 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):\n",
163-
" sources = await get_sources(search_client, query, search_type, use_semantic_reranker, sources_to_include, k)\n",
159+
" async def append_grounded_message(self, search_client: SearchClient, query: str, search_type: SearchType, use_semantic_reranker: bool = True, sources_to_include: int = 5):\n",
160+
" sources = await get_sources(search_client, query, search_type, use_semantic_reranker, sources_to_include)\n",
164161
" sources_formatted = \"\\n\".join([f'{document[\"HotelName\"]}:{document[\"Description\"]}:{document[\"Tags\"]}' for document in sources])\n",
165162
" self.append_message(role=\"user\", message=GROUNDED_PROMPT.format(query=query, sources=sources_formatted))\n",
166163
" self.search_results.append(\n",

0 commit comments

Comments
 (0)