simple-sveltekit-rag
Simple-SvelteKit-RAG is based on https://github.com/pixegami/langchain-rag-tutorial and shows how the RAG
pattern
can be implemented into a simple web app. The visualization helps to make the topic more easily understandable.
Setup
Prerequisites
- Node
- ChromaDB running on port 8000 (see below)
- OpenAI api key with about 0.05$ of credits (this will probably last a few hundred requests)
Quick start
Start ChromaDB on port 8000. Most easily done by using docker:
docker pull chromadb/chroma
docker run -d --name ChromaDB -p 8000:8000 -v chroma-data:/chroma/chroma chromadb/chroma
Install requirements
Clone the GitHub repository and navigate into the SvelteKit-RAG folder. Run npm install.
Setup .env file
- Copy the env.example file and rename it to .env
- Fill in your api key from OpenAI
- Leave the collection name as is (this can be changed if you want to have multiple collections of data hosted on
a
single ChromaDB)
- The similarity score threshold can be used to control how similar the most similar found document chunk has to be
to
the
query in order continue with the generation step (lower → more similar). If the threshold is not met the
program will abort and
show an error.
Execute the program
Run npm run dev inside the SvelteKit-RAG folder and open https://localhost:5173 in your browser.
Usage
There are two pages within the app. You can navigate between them using the cyan buttons:
- https://localhost:5173/: Query page
On this page you can query the system. After sending your query you should get a response within a few seconds.
Along with the response the page will show you the sources used along with the similarity score. You can click
on
them to see the content of the source chunk.
- https://localhost:5173/database: Upload/Database monitoring page
On this page you can see the chunks saved in the database and upload files to write into the database.
Use the file input at the top to upload multiple markdown files and send your request using the green button.
After a few seconds you can see the chunks that are now in your database. You can now query these on the query
page.
Attention: When you upload files the entire database gets overwritten. There is no option to upload additional
documents.