Skip to content

Commit 73de307

Browse files
committed
Update rag.md
1 parent 8949e68 commit 73de307

File tree

1 file changed

+10
-10
lines changed
  • articles/cosmos-db/mongodb/vcore

1 file changed

+10
-10
lines changed

articles/cosmos-db/mongodb/vcore/rag.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ index_name = "ContosoIndex"
129129
collection = db[collection_name]
130130
```
131131

132-
1. Initialize the Embedding Client.
132+
2. Initialize the Embedding Client.
133133
```python
134134
from langchain_openai import AzureOpenAIEmbeddings
135135

@@ -142,7 +142,7 @@ azure_openai_embeddings: AzureOpenAIEmbeddings = AzureOpenAIEmbeddings(
142142
)
143143
```
144144

145-
1. Create embeddings from the data, save to the database and return a connection to your vector store, Cosmos DB for MongoDB (vCore).
145+
3. Create embeddings from the data, save to the database and return a connection to your vector store, Cosmos DB for MongoDB (vCore).
146146
```python
147147
vector_store: AzureCosmosDBVectorSearch = AzureCosmosDBVectorSearch.from_documents(
148148
json_data,
@@ -152,7 +152,7 @@ vector_store: AzureCosmosDBVectorSearch = AzureCosmosDBVectorSearch.from_documen
152152
)
153153
```
154154

155-
1. Create the following [HNSW vector Index](./vector-search.md) on the collection, (Note the name of the index is same as above).
155+
4. Create the following [HNSW vector Index](./vector-search.md) on the collection, (Note the name of the index is same as above).
156156
```python
157157
num_lists = 100
158158
dimensions = 1536
@@ -177,22 +177,22 @@ vector_store: AzureCosmosDBVectorSearch = AzureCosmosDBVectorSearch.from_connec
177177
)
178178
```
179179

180-
1. Define a function that performs semantic similarity search using Cosmos DB Vector Search on a query (note this code snippet is just a test function).
180+
2. Define a function that performs semantic similarity search using Cosmos DB Vector Search on a query (note this code snippet is just a test function).
181181
```python
182182
query = "beef dishes"
183183
docs = vector_store.similarity_search(query)
184184
print(docs[0].page_content)
185185
```
186186

187-
1. Initialize the Chat Client to implement a RAG function.
187+
3. Initialize the Chat Client to implement a RAG function.
188188
```python
189189
azure_openai_chat: AzureChatOpenAI = AzureChatOpenAI(
190190
model=openai_chat_model,
191191
azure_deployment=openai_chat_deployment,
192192
)
193193
```
194194

195-
1. Create a RAG function.
195+
4. Create a RAG function.
196196
```python
197197
history_prompt = ChatPromptTemplate.from_messages(
198198
[
@@ -215,24 +215,24 @@ context_prompt = ChatPromptTemplate.from_messages(
215215
)
216216
```
217217

218-
1. Converts the vector store into a retriever, which can search for relevant documents based on specified parameters.
218+
5. Converts the vector store into a retriever, which can search for relevant documents based on specified parameters.
219219
```python
220220
vector_store_retriever = vector_store.as_retriever(
221221
search_type=search_type, search_kwargs={"k": limit, "score_threshold": score_threshold}
222222
)
223223
```
224224

225-
1. Create a retriever chain that is aware of the conversation history, ensuring contextually relevant document retrieval using the **azure_openai_chat** model and **vector_store_retriever**.
225+
6. Create a retriever chain that is aware of the conversation history, ensuring contextually relevant document retrieval using the **azure_openai_chat** model and **vector_store_retriever**.
226226
```python
227227
retriever_chain = create_history_aware_retriever(azure_openai_chat, vector_store_retriever, history_prompt)
228228
```
229229

230-
1. Create a chain that combines retrieved documents into a coherent response using the language model (**azure_openai_chat**) and a specified prompt (**context_prompt**).
230+
7. Create a chain that combines retrieved documents into a coherent response using the language model (**azure_openai_chat**) and a specified prompt (**context_prompt**).
231231
```python
232232
context_chain = create_stuff_documents_chain(llm=azure_openai_chat, prompt=context_prompt)
233233
```
234234

235-
1. Create a chain that handles the entire retrieval process, integrating the history-aware retriever chain and the document combination chain. This RAG chain can be executed to retrieve and generate contextually accurate responses.
235+
8. Create a chain that handles the entire retrieval process, integrating the history-aware retriever chain and the document combination chain. This RAG chain can be executed to retrieve and generate contextually accurate responses.
236236
```python
237237
rag_chain: Runnable = create_retrieval_chain(
238238
retriever=retriever_chain,

0 commit comments

Comments
 (0)