@@ -42,7 +42,7 @@ If you already have a search index with data, you can skip to [Get product docum
42
42
43
43
Create an ** assets** directory and add this example data to a ** products.csv** file:
44
44
45
- :::code language="csv" source="~ /azureai-samples-nov2024 /scenarios/rag/custom-rag-app/assets/products.csv":::
45
+ :::code language="csv" source="~ /azureai-samples-main /scenarios/rag/custom-rag-app/assets/products.csv":::
46
46
47
47
## Create a search index
48
48
@@ -52,19 +52,19 @@ The search index is used to store vectorized data from the embeddings model. The
52
52
1 . Copy and paste the following code into your ** create_search_index.py** file.
53
53
1 . Add the code to import the required libraries, create a project client, and configure some settings:
54
54
55
- :::code language="python" source="~ /azureai-samples-nov2024 /scenarios/rag/custom-rag-app/create_search_index.py" id="imports_and_config":::
55
+ :::code language="python" source="~ /azureai-samples-main /scenarios/rag/custom-rag-app/create_search_index.py" id="imports_and_config":::
56
56
57
57
1 . Now add the function to define a search index:
58
58
59
- :::code language="python" source="~ /azureai-samples-nov2024 /scenarios/rag/custom-rag-app/create_search_index.py" id="create_search_index":::
59
+ :::code language="python" source="~ /azureai-samples-main /scenarios/rag/custom-rag-app/create_search_index.py" id="create_search_index":::
60
60
61
61
1 . Create the function to add a csv file to the index:
62
62
63
- :::code language="python" source="~ /azureai-samples-nov2024 /scenarios/rag/custom-rag-app/create_search_index.py" id="add_csv_to_index":::
63
+ :::code language="python" source="~ /azureai-samples-main /scenarios/rag/custom-rag-app/create_search_index.py" id="add_csv_to_index":::
64
64
65
65
1 . Finally, run the functions to build the index and register it to the cloud project:
66
66
67
- :::code language="python" source="~ /azureai-samples-nov2024 /scenarios/rag/custom-rag-app/create_search_index.py" id="test_create_index":::
67
+ :::code language="python" source="~ /azureai-samples-main /scenarios/rag/custom-rag-app/create_search_index.py" id="test_create_index":::
68
68
69
69
1 . From your console, log in to your Azure account and follow instructions for authenticating your account:
70
70
@@ -95,23 +95,23 @@ When the chat gets a request, it searches through your data to find relevant inf
95
95
96
96
1. Start with code to import the required libraries, create a project client, and configure settings:
97
97
98
- :::code language=" python" source=" ~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/get_product_documents.py" id=" imports_and_config" :::
98
+ :::code language=" python" source=" ~/azureai-samples-main /scenarios/rag/custom-rag-app/get_product_documents.py" id=" imports_and_config" :::
99
99
100
100
1. Add the function to get product documents:
101
101
102
- :::code language=" python" source=" ~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/get_product_documents.py" id=" get_product_documents" :::
102
+ :::code language=" python" source=" ~/azureai-samples-main /scenarios/rag/custom-rag-app/get_product_documents.py" id=" get_product_documents" :::
103
103
104
104
1. Finally, add code to test the function when you run the script directly:
105
105
106
- :::code language=" python" source=" ~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/get_product_documents.py" id=" test_get_documents" :::
106
+ :::code language=" python" source=" ~/azureai-samples-main /scenarios/rag/custom-rag-app/get_product_documents.py" id=" test_get_documents" :::
107
107
108
108
# ## Create prompt template for intent mapping
109
109
110
110
The ** get_product_documents.py** script uses a prompt template to convert the conversation to a search query. The template instructs how to extract the user' s intent from the conversation.
111
111
112
112
Before you run the script, create the prompt template. Add the file **intent_mapping.prompty** to your **assets** folder:
113
113
114
- :::code language="prompty" source="~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/assets/intent_mapping.prompty":::
114
+ :::code language="prompty" source="~/azureai-samples-main /scenarios/rag/custom-rag-app/assets/intent_mapping.prompty":::
115
115
116
116
### Test the product document retrieval script
117
117
@@ -130,23 +130,23 @@ Next you create custom code to add retrieval augmented generation (RAG) capabili
130
130
1. In your main folder, create a new file called **chat_with_products.py**. This script retrieves product documents and generates a response to a user' s question.
131
131
1. Add the code to import the required libraries, create a project client, and configure settings:
132
132
133
- :::code language=" python" source=" ~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/chat_with_products.py" id=" imports_and_config" :::
133
+ :::code language=" python" source=" ~/azureai-samples-main /scenarios/rag/custom-rag-app/chat_with_products.py" id=" imports_and_config" :::
134
134
135
135
1. Create the chat function that uses the RAG capabilities:
136
136
137
- :::code language=" python" source=" ~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/chat_with_products.py" id=" chat_function" :::
137
+ :::code language=" python" source=" ~/azureai-samples-main /scenarios/rag/custom-rag-app/chat_with_products.py" id=" chat_function" :::
138
138
139
139
1. Finally, add the code to run the chat function:
140
140
141
- :::code language=" python" source=" ~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/chat_with_products.py" id=" test_function" :::
141
+ :::code language=" python" source=" ~/azureai-samples-main /scenarios/rag/custom-rag-app/chat_with_products.py" id=" test_function" :::
142
142
143
143
# ## Create a grounded chat prompt template
144
144
145
145
The ** chat_with_products.py** script calls a prompt template to generate a response to the user' s question. The template instructs how to generate a response based on the user' s question and the retrieved documents. Create this template now.
146
146
147
147
In your ** assets** folder, add the file ** grounded_chat.prompty** :
148
148
149
- :::code language=" prompty" source=" ~/azureai-samples-nov2024 /scenarios/rag/custom-rag-app/assets/grounded_chat.prompty" :::
149
+ :::code language=" prompty" source=" ~/azureai-samples-main /scenarios/rag/custom-rag-app/assets/grounded_chat.prompty" :::
150
150
151
151
# ## Run the chat script with RAG capabilities
152
152
@@ -156,7 +156,7 @@ Now that you have both the script and the template, run the script to test your
156
156
python chat_with_products.py --query " I need a new tent for 4 people, what would you recommend?"
157
157
` ` `
158
158
159
- To enable logging of telemetry to your project:
159
+ < ! -- To enable logging of telemetry to your project:
160
160
161
161
1. Install ` azure-monitor-opentelemetry` :
162
162
@@ -167,7 +167,7 @@ To enable logging of telemetry to your project:
167
167
1. Add the ` --enable-telemetry` flag when you use the ` chat_with_products.py` script:
168
168
169
169
` ` ` bash
170
- python chat_with_products.py --query " I need a new tent for 4 people, what would you recommend?" --enable-telemetry
170
+ python chat_with_products.py --query " I need a new tent for 4 people, what would you recommend?" --enable-telemetry -- >
171
171
` ` `
172
172
173
173
# # Clean up resources
0 commit comments