Skip to content

Commit 688a512

Browse files
committed
Added a requirements.txt file for RAG quickstart
1 parent 5195a71 commit 688a512

File tree

2 files changed

+51
-19
lines changed

2 files changed

+51
-19
lines changed

Quickstart-RAG/Quickstart-rag.ipynb

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@
4141
"\n",
4242
"This quickstart assumes authentication and authorization using Microsoft Entra ID and role assignments. It also assumes that you run this code from your local device.\n",
4343
"\n",
44-
"- On Azure AI Search, create a role assignment for the Azure OpenAI system managed identity. Required roles: **Search Index Data Reader**, **Search Service Contributor**.\n",
44+
"1. To create and load the sample index on Azure AI Search, you must have role assignments for: **Search Index Data Reader**, **Search Index Data Contributor**, **Search Service Contributor**.\n",
4545
"\n",
46-
"- Make sure you also have a role assignment that gives you permissions to create and query objects: Required roles: **Search Index Data Reader**, **Search Index Data Contributor**, **Search Service Contributor**.\n",
47-
"\n",
48-
"- On Azure OpenAI, create a role assigment for yourself to send requests from your local device: Required role: **Cognitive Services OpenAI User**.\n",
46+
"1. To send the query and results from the search engine to Azure OpenAI, the search system identity must have **Cognitive Services OpenAI User** permissions on Azure OpenAI.\n",
4947
"\n",
5048
"## Create the sample index\n",
5149
"\n",
@@ -72,33 +70,44 @@
7270
"Now that you have your Azure resources, an index, and model in place, you can run the script to chat with the index."
7371
]
7472
},
73+
{
74+
"cell_type": "markdown",
75+
"metadata": {},
76+
"source": [
77+
"## Run the code\n",
78+
"\n",
79+
"1. Create a virtual environment. In Visual Studio Code, press Ctrl-shift-P to open the command palette, search for \"Python: Create Environment\", and then select `Venv` to create a virtual environment in the current workspace.\n",
80+
"\n",
81+
"1. Select Quickstart-RAG\\requirements.txt for the dependencies.\n",
82+
"\n",
83+
"It takes several minutes to create the environment. When the environment is ready, continue to the next step."
84+
]
85+
},
7586
{
7687
"cell_type": "code",
77-
"execution_count": null,
88+
"execution_count": 6,
7889
"metadata": {},
7990
"outputs": [],
8091
"source": [
8192
"# Package install for quickstart\n",
82-
"! pip install azure-search-documents==11.6.0b4 --quiet\n",
83-
"! pip install azure-identity==1.16.0 --quiet\n",
84-
"! pip install openai --quiet"
93+
"! pip install -r requirements.txt --quiet"
8594
]
8695
},
8796
{
8897
"cell_type": "code",
89-
"execution_count": null,
98+
"execution_count": 7,
9099
"metadata": {},
91100
"outputs": [],
92101
"source": [
93-
"# Set endpoints and deployment model\n",
94-
"AZURE_SEARCH_SERVICE: str = \"PUT YOUR SEARCH SERVICE ENDPOINT HERE\"\n",
95-
"AZURE_OPENAI_ACCOUNT: str = \"PUT YOUR AZURE OPENAI ENDPOINT HERE\"\n",
96-
"AZURE_DEPLOYMENT_MODEL: str = \"gpt-35-turbo\""
102+
"# Set endpoints and deployment model (provide the name of the deployment)\n",
103+
" AZURE_SEARCH_SERVICE: str = \"PUT YOUR SEARCH SERVICE ENDPOINT HERE\"\n",
104+
" AZURE_OPENAI_ACCOUNT: str = \"PUT YOUR AZURE OPENAI ENDPOINT HERE\"\n",
105+
" AZURE_DEPLOYMENT_MODEL: str = \"gpt-35-turbo\""
97106
]
98107
},
99108
{
100109
"cell_type": "code",
101-
"execution_count": null,
110+
"execution_count": 8,
102111
"metadata": {},
103112
"outputs": [],
104113
"source": [
@@ -110,7 +119,7 @@
110119
},
111120
{
112121
"cell_type": "code",
113-
"execution_count": null,
122+
"execution_count": 16,
114123
"metadata": {},
115124
"outputs": [],
116125
"source": [
@@ -203,9 +212,21 @@
203212
},
204213
{
205214
"cell_type": "code",
206-
"execution_count": null,
215+
"execution_count": 19,
207216
"metadata": {},
208-
"outputs": [],
217+
"outputs": [
218+
{
219+
"name": "stdout",
220+
"output_type": "stream",
221+
"text": [
222+
"Based on your preferences, I recommend the following hotels: \n",
223+
"\n",
224+
"- Ocean Air Motel: This hotel is oceanfront with beach access, two pools, and a private balcony with ocean views. \n",
225+
"- Marquis Plaza & Suites: This hotel has a view of the ocean and amenities like free Wi-Fi, a full kitchen, and a free breakfast buffet. \n",
226+
"- Trails End Motel: Though not directly on the ocean, this hotel does have a view and is only 8 miles from downtown. Amenities include an on-site bar/restaurant, free hot breakfast buffet, and free Wi-Fi.\n"
227+
]
228+
}
229+
],
209230
"source": [
210231
"# Instantiate the chat thread and run the conversation\n",
211232
"import azure.identity.aio\n",
@@ -219,12 +240,19 @@
219240
" query=\"Can you recommend a few hotels near the ocean with beach access and good views\",\n",
220241
" search_type=SearchType(search_type),\n",
221242
" use_semantic_reranker=use_semantic_reranker,\n",
222-
" sources_to_include=sources_to_include,\n",
223-
" k=k)\n",
243+
" sources_to_include=sources_to_include\n",
244+
" )\n",
224245
" await chat_thread.get_openai_response(openai_client=openai_client, model=chat_deployment)\n",
225246
"\n",
226247
"print(chat_thread.get_last_message()[\"content\"])"
227248
]
249+
},
250+
{
251+
"cell_type": "markdown",
252+
"metadata": {},
253+
"source": [
254+
"If you get an authorization error message, wait a few minutes and try again. It can take several minutes for role assignments to become operational."
255+
]
228256
}
229257
],
230258
"metadata": {

Quickstart-RAG/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
azure-search-documents==11.6.0b4
2+
azure-identity==1.16.0
3+
openai
4+
aiohttp

0 commit comments

Comments
 (0)