GitHub repo | Open in StackBlitz
An example demonstrating Retrieval Augmented Generation (RAG) using SQLRooms and DuckDB for vector search. Features include:
- AI chat with RAG: ask questions and get answers based on relevant documentation
- Direct RAG search UI to query embedded documentation
- Vector embeddings stored in DuckDB with native vector similarity search
- Integration with OpenAI for embeddings and chat responses
To create a new project from the ai-rag example run this:
npx giget gh:sqlrooms/examples/ai-rag my-new-app/First, generate vector embeddings of the DuckDB documentation using the sqlrooms-rag package:
# Download DuckDB docs
npx giget gh:duckdb/duckdb-web/docs ./duckdb-docs
# Generate embeddings with OpenAI (requires OPENAI_API_KEY env var)
OPENAI_API_KEY=your-key uvx --from sqlrooms-rag prepare-embeddings ./duckdb-docs -o public/rag/duckdb_docs.duckdb --provider openaiThis will process all markdown files and create a DuckDB database with 1536-dim OpenAI embeddings at public/rag/duckdb_docs.duckdb.
The app requires an OpenAI API key for:
- Generating embeddings for your search queries (on the fly)
- Powering the AI chat responses
You'll be prompted to enter your API key when you start the app, or you can set it in the settings.
npm install
npm run devThen open the app and:
- Enter your OpenAI API key in the settings
- Click the search icon to test RAG search directly
- Use the AI chat to ask questions about DuckDB
