This sample project demonstrates a Retrieval-Augmented Generation (RAG) enabled voice agent using LiveKit Agents 1.0. The example scrapes the LiveKit docs site, builds a local index, and then provides that data on demand to the assistant via a function tool.
- Python 3.9 or higher
- OpenAI API key
- Deepgram API key
- LiveKit server
- Clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file in the project root with your API keys:OPENAI_API_KEY=your_openai_api_key DEEPGRAM_API_KEY=your_deepgram_api_key LIVEKIT_URL=your_livekit_url LIVEKIT_API_KEY=your_livekit_api_key LIVEKIT_API_SECRET=your_livekit_api_secret
main.py
: Main agent implementationscrape_docs.py
: Scraper for the LiveKit docs sitebuild_rag_data.py
: Script to build the RAG database from scraped docsrag_db_builder.py
: Database builder implementationrag_handler.py
: RAG processing logicdata/
: Directory for vector database files
-
Scrape the docs site:
python scrape_docs.py
-
Build the RAG database:
python build_rag_data.py
-
Download model files:
python main.py download-files
-
Run the agent:
python main.py console
The agent will start and be ready to handle voice interactions. It will use the RAG system to provide contextually relevant answers to user questions.