How shaynep/livekit-rag-thinking works
This repository is a LiveKit voice assistant demo that answers LiveKit questions using retrieval-augmented generation. A user speaks through LiveKit; the voice pipeline transcribes input and invokes the registered RAG function, which announces a lookup, embeds the question, searches the Annoy index, enriches chat context, and speaks the generated answer. The separate data-building stage embeds paragraphs from raw_data.txt and saves the index and paragraph lookup. README documents alternative delay messages; source excerpts show static text enabled and audio/LLM-generated alternatives commented out.
Main entry points: agent.py RAG function · build_data.py Paragraph tokenizing · raw_data.txt Knowledge text · let_me_check_that.wav Recorded prompt
Components 21
Knowledge preparation
- Knowledge text
raw_data.txt - Paragraph tokenizing
build_data.py - Embedding creation
build_data.py - Index construction
build_data.py - Annoy index
build_data.py - Paragraph lookup
build_data.py
Voice assistant
- Agent entrypoint
agent.py - Voice pipeline
agent.py - Speech recognition
agent.py - Speech synthesis
agent.py
Retrieval and response
- RAG function
agent.py - Question embedding
agent.py - Similarity search
agent.py - Context enrichment
agent.py - LLM response
agent.py
Delay handling
- Static messages
agent.py - Generated messages
agent.py - Audio playback
agent.py - Recorded prompt
let_me_check_that.wav
Other components
- Voice user
- LiveKit room
Connections 22
- Knowledge text → Paragraph tokenizing: tokenizes
build_data.py - Paragraph tokenizing → Embedding creation: embeds paragraphs
build_data.py - Embedding creation → Index construction: adds vectors
build_data.py - Index construction → Annoy index: saves index
build_data.py - Paragraph tokenizing → Paragraph lookup: saves lookup
build_data.py - Voice user → LiveKit room: speaks through
README.md - LiveKit room → Agent entrypoint: connects
agent.py - Agent entrypoint → Voice pipeline: starts
agent.py - Voice pipeline → Speech recognition: transcribes
README.md - Voice pipeline → Speech synthesis: speaks responses
README.md - Voice pipeline → RAG function: invokes
agent.py - RAG function → Static messages: announces lookup
agent.py - RAG function → Context enrichment: runs lookup
agent.py - Context enrichment → Question embedding: embeds question
agent.py - Context enrichment → Similarity search: queries
agent.py - Similarity search → Annoy index: searches
agent.py - Similarity search → Paragraph lookup: looks up result
agent.py - Context enrichment → LLM response: requests answer
agent.py - LLM response → Voice pipeline: returns speech stream
agent.py - RAG function → Generated messages: may generate
README.md - RAG function → Audio playback: may play
README.md - Audio playback → Recorded prompt: plays
agent.py