You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a tutorial for how to build your own generic RAG chatbot. It is intended as a foundation for building more complex, domain-specific RAG bots. Note that no GPU is needed to run this as it is using NIMs from the NVIDIA catalog.
3
+
This implementation is tied to the [YouTube video on NVIDIA Developer](https://youtu.be/N_OOfkEWcOk).
4
4
5
-
## Acknowledgements
5
+
This is a simple standalone implementation showing a minimal RAG pipeline that uses models available from [NVIDIA API Catalog](https://catalog.ngc.nvidia.com/ai-foundation-models).
6
+
The catalog enables you to experience state-of-the-art LLMs accelerated by NVIDIA.
7
+
Developers get free credits for 10K requests to any of the models.
6
8
7
-
- This implementation is based on [Rag in 5 Minutes](https://github.com/NVIDIA/GenerativeAIExamples/tree/4e86d75c813bcc41d4e92e430019053920d08c94/community/5_mins_rag_no_gpu), with changes primarily made to the UI.
8
-
- Alyssa Sawyer also contributed to updating and further developing this repo during her intern project, [Resume RAG Bot](https://github.com/alysawyer/resume-rag-nv), at NVIDIA.
9
+
The example uses an [integration package to LangChain](https://python.langchain.com/docs/integrations/providers/nvidia) to access the models.
10
+
NVIDIA engineers develop, test, and maintain the open source integration.
11
+
This example uses a simple [Streamlit](https://streamlit.io/) based user interface and has a one-file implementation.
12
+
Because the example uses the models from the NVIDIA API Catalog, you do not need a GPU to run the example.
9
13
10
-
## Steps
14
+
###Steps
11
15
12
16
1. Create a python virtual environment and activate it:
13
17
@@ -16,10 +20,10 @@ This is a tutorial for how to build your own generic RAG chatbot. It is intended
16
20
source genai/bin/activate
17
21
```
18
22
19
-
1. From the root of this repository, install the requirements:
23
+
1. From the root of this repository, `GenerativeAIExamples`, install the requirements:
1. Add your NVIDIA API key as an environment variable:
@@ -28,15 +32,17 @@ This is a tutorial for how to build your own generic RAG chatbot. It is intended
28
32
export NVIDIA_API_KEY="nvapi-*"
29
33
```
30
34
31
-
If you don't already have an API key, visit the [NVIDIA API Catalog](https://build.ngc.nvidia.com/explore/), select on any model, then click on `Get API Key`.
35
+
If you don't already have an API key, visit the [NVIDIA API Catalog](https://build.ngc.nvidia.com/explore/), select on any model, then click on `Get API Key`.
32
36
33
37
1. Run the example using Streamlit:
34
38
35
39
```console
36
-
streamlit run main.py
40
+
streamlit run community/5_mins_rag_no_gpu/main.py
37
41
```
38
42
39
43
1. Test the deployed example by going to `http://<host_ip>:8501` in a web browser.
40
44
41
-
Click **Browse Files** and select the documents for your knowledge base.
42
-
After selecting, click **Upload!** to complete the ingestion process.
45
+
Click **Browse Files** and select your knowledge source.
46
+
After selecting, click **Upload!** to complete the ingestion process.
47
+
48
+
You are all set now! Try out queries related to the knowledge base using text from the user interface.
st.markdown('''Manually looking through vast amounts of data can be tedious and time-consuming. This chatbot can expedite that process by providing a platform to query your documents.''')
45
-
st.warning("This is a proof of concept, and any output from the AI agent should be used in conjunction with the original data.", icon="⚠️")
46
-
47
-
############################################
48
-
# Component #1 - Document Loader
49
-
############################################
29
+
st.set_page_config(layout="wide")
50
30
31
+
# Component #1 - Document Upload
51
32
withst.sidebar:
52
-
st.subheader("Upload Your Documents")
53
-
54
33
DOCS_DIR=os.path.abspath("./uploaded_docs")
55
-
56
-
# Make dir to store uploaded documents
57
34
ifnotos.path.exists(DOCS_DIR):
58
35
os.makedirs(DOCS_DIR)
59
-
60
-
# Define form on Streamlit page for uploading files to KB
61
36
st.subheader("Add to the Knowledge Base")
62
37
withst.form("my-form", clear_on_submit=True):
63
38
uploaded_files=st.file_uploader("Upload a file to the Knowledge Base:", accept_multiple_files=True)
("system", "You are a helpful AI assistant. Use the provided contextto inform your responses. If no context is available, please state that."),
93
+
("system", "You are a helpful AI assistant named Envie. If provided with context, use it to inform your responses. If no context is available, use your general knowledge to provide a helpful response."),
154
94
("human", "{input}")
155
95
])
156
96
157
-
# Define simple prompt chain
158
97
chain=prompt_template|llm|StrOutputParser()
159
98
160
-
# Display an example query for user
161
-
user_query=st.chat_input("Please summarize these documents.")
99
+
user_input=st.chat_input("Can you tell me what NVIDIA is known for?")
0 commit comments