Skip to content

Commit 42714d3

Browse files
authored
[Docs] - Vector Store RAG Starter Flow (langflow-ai#1850)
* initial-content * additional-query
1 parent a037bf9 commit 42714d3

File tree

5 files changed

+111
-3
lines changed

5 files changed

+111
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import ThemedImage from "@theme/ThemedImage";
2+
import useBaseUrl from "@docusaurus/useBaseUrl";
3+
import ZoomableImage from "/src/theme/ZoomableImage.js";
4+
import ReactPlayer from "react-player";
5+
import Admonition from "@theme/Admonition";
6+
7+
# Vector store RAG
8+
9+
Retrieval Augmented Generation, or RAG, is a pattern for training LLMs on your data and querying it.
10+
11+
RAG is backed by a **vector store**, a vector database which stores embeddings of the ingested data.
12+
13+
This enables **vector search**, a more powerful and context-aware search.
14+
15+
We've chosen [Astra DB](https://astra.datastax.com/signup?utm_source=langflow-pre-release&utm_medium=referral&utm_campaign=langflow-announcement&utm_content=create-a-free-astra-db-account) as the vector database for this starter project, but you can follow along with any of Langflow's vector database options.
16+
17+
## Prerequisites
18+
19+
<Admonition type="info">
20+
Langflow v1.0 alpha is also available in [HuggingFace Spaces](https://huggingface.co/spaces/Langflow/Langflow-Preview?duplicate=true). Try it out or follow the instructions [here](../getting-started/huggingface-spaces) to install it locally.
21+
</Admonition>
22+
23+
* [Langflow installed](../getting-started/install-langflow.mdx)
24+
25+
* [OpenAI API key](https://platform.openai.com)
26+
27+
* [An Astra DB vector database created](https://docs.datastax.com/en/astra-db-serverless/get-started/quickstart.html) with:
28+
* Application token (`AstraCS:WSnyFUhRxsrg…​`)
29+
* API endpoint (`https://ASTRA_DB_ID-ASTRA_DB_REGION.apps.astra.datastax.com`)
30+
31+
## Create the vector store RAG project
32+
33+
1. From the Langflow dashboard, click **New Project**.
34+
2. Select **Vector Store RAG**.
35+
3. The **Vector Store RAG** flow is created.
36+
37+
<ZoomableImage
38+
alt="Docusaurus themed image"
39+
sources={{
40+
light: "img/vector-store-rag.png",
41+
dark: "img/vector-store-rag.png",
42+
}}
43+
style={{ width: "80%", margin: "20px auto" }}
44+
/>
45+
46+
The vector store RAG flow is built of two separate flows.
47+
48+
The **ingestion** flow (bottom of the screen) populates the vector store with data from a local file.
49+
It ingests data from a file (**File**), splits it into chunks (**Recursive Character Text Splitter**), indexes it in Astra DB (**Astra DB**), and computes embeddings for the chunks (**OpenAI Embeddings**).
50+
This forms a "brain" for the query flow.
51+
52+
The **query** flow (top of the screen) allows users to chat with the embedded vector store data. It's a little more complex:
53+
54+
* **Chat Input** component defines where to put the user input coming from the Playground.
55+
* **OpenAI Embeddings** component generates embeddings from the user input.
56+
* **Astra DB Search** component retrieves the most relevant Records from the Astra DB database.
57+
* **Text Output** component turns the Records into Text by concatenating them and also displays it in the Playground.
58+
* **Prompt** component takes in the user input and the retrieved Records as text and builds a prompt for the OpenAI model.
59+
* **OpenAI** component generates a response to the prompt.
60+
* **Chat Output** component displays the response in the Playground.
61+
62+
4. To create an environment variable for the **OpenAI** component, in the **OpenAI API Key** field, click the **Globe** button, and then click **Add New Variable**.
63+
1. In the **Variable Name** field, enter `openai_api_key`.
64+
2. In the **Value** field, paste your OpenAI API Key (`sk-...`).
65+
3. Click **Save Variable**.
66+
67+
4. To create environment variables for the **Astra DB** and **Astra DB Search** components:
68+
1. In the **Token** field, click the **Globe** button, and then click **Add New Variable**.
69+
2. In the **Variable Name** field, enter `astra_token`.
70+
3. In the **Value** field, paste your Astra application token (`AstraCS:WSnyFUhRxsrg…​`).
71+
4. Click **Save Variable**.
72+
5. Repeat the above steps for the **API Endpoint** field, pasting your Astra API Endpoint instead (`https://ASTRA_DB_ID-ASTRA_DB_REGION.apps.astra.datastax.com`).
73+
6. Add the global variable to both the **Astra DB** and **Astra DB Search** components.
74+
75+
## Run the vector store RAG flow
76+
77+
1. Click the **Playground** button.
78+
The **Playground** opens, where you can chat with your data.
79+
2. Type a message and press Enter. (Try something like "What topics do you know about?")
80+
3. The bot will respond with a summary of the data you've embedded.
81+
82+
For example, we embedded a PDF of an engine maintenance manual and asked, "How do I change the oil?"
83+
The bot responds:
84+
```
85+
To change the oil in the engine, follow these steps:
86+
87+
Make sure the engine is turned off and cool before starting.
88+
89+
Locate the oil drain plug on the bottom of the engine.
90+
91+
Place a drain pan underneath the oil drain plug to catch the old oil...
92+
```
93+
94+
We can also get more specific:
95+
96+
```
97+
User
98+
What size wrench should I use to remove the oil drain cap?
99+
100+
AI
101+
You should use a 3/8 inch wrench to remove the oil drain cap.
102+
```
103+
104+
This is the size the engine manual lists as well. This confirms our flow works, because the query returns the unique knowledge we embedded from the Astra vector store.
105+
106+
107+
108+

docs/sidebars.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
"starter-projects/blog-writer",
3030
"starter-projects/document-qa",
3131
"starter-projects/memory-chatbot",
32-
"tutorials/rag-with-astradb"
32+
"starter-projects/vector-store-rag"
3333
],
3434
},
3535
{

docs/static/data/AstraDB-RAG-Flows.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3396,7 +3396,7 @@
33963396
"zoom": 0.2687057134854984
33973397
}
33983398
},
3399-
"description": "Visit https://pre-release.langflow.org/guides/rag-with-astradb for a detailed guide of this project.\nThis project give you both Ingestion and RAG in a single file. You'll need to visit https://astra.datastax.com/ to create an Astra DB instance, your Token and grab an API Endpoint.\nRunning this project requires you to add a file in the Files component, then define a Collection Name and click on the Play icon on the Astra DB component. \n\nAfter the ingestion ends you are ready to click on the Run button at the lower left corner and start asking questions about your data.",
3399+
"description": "Visit https://pre-release.langflow.org/tutorials/rag-with-astradb for a detailed guide of this project.\nThis project give you both Ingestion and RAG in a single file. You'll need to visit https://astra.datastax.com/ to create an Astra DB instance, your Token and grab an API Endpoint.\nRunning this project requires you to add a file in the Files component, then define a Collection Name and click on the Play icon on the Astra DB component. \n\nAfter the ingestion ends you are ready to click on the Run button at the lower left corner and start asking questions about your data.",
34003400
"name": "Vector Store RAG",
34013401
"last_tested_version": "1.0.0a0",
34023402
"is_component": false

docs/static/img/vector-store-rag.png

838 KB
Loading

src/backend/base/langflow/initial_setup/starter_projects/VectorStore-RAG-Flows.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3403,7 +3403,7 @@
34033403
"zoom": 0.2687057134854984
34043404
}
34053405
},
3406-
"description": "Visit https://pre-release.langflow.org/guides/rag-with-astradb for a detailed guide of this project.\nThis project give you both Ingestion and RAG in a single file. You'll need to visit https://astra.datastax.com/ to create an Astra DB instance, your Token and grab an API Endpoint.\nRunning this project requires you to add a file in the Files component, then define a Collection Name and click on the Play icon on the Astra DB component. \n\nAfter the ingestion ends you are ready to click on the Run button at the lower left corner and start asking questions about your data.",
3406+
"description": "Visit https://pre-release.langflow.org/tutorials/rag-with-astradb for a detailed guide of this project.\nThis project give you both Ingestion and RAG in a single file. You'll need to visit https://astra.datastax.com/ to create an Astra DB instance, your Token and grab an API Endpoint.\nRunning this project requires you to add a file in the Files component, then define a Collection Name and click on the Play icon on the Astra DB component. \n\nAfter the ingestion ends you are ready to click on the Run button at the lower left corner and start asking questions about your data.",
34073407
"name": "Vector Store RAG",
34083408
"last_tested_version": "1.0.0a0",
34093409
"is_component": false

0 commit comments

Comments
 (0)