happy-fall-6105
08/26/2025, 8:22 AMtall-airline-16756
08/26/2025, 8:22 AMtall-airline-16756
08/26/2025, 8:22 AMhappy-fall-6105
08/26/2025, 8:24 AMtall-airline-16756
08/26/2025, 8:24 AMfrom rag_db_builder import RAGBuilder
# Extracted text from your PDF
pdf_text = "Extracted content from your PDF file"
pdf_paragraphs = tokenize.basic.tokenize_paragraphs(pdf_text) # Split into paragraphs
# Build RAG database
builder = RAGBuilder(
index_path="data/index.annoy",
data_path="data/paragraphs.pkl",
embeddings_dimension=1536
)
await builder.build_from_texts(pdf_paragraphs)
1. Query the Database: Use the RAGHandler to fetch relevant info from your database and weave it into your agent’s responses.
2. Alternative Approach: You can also use the on_user_turn_completed lifecycle hook to sneak in the retrieved context right before generating a response.
If you want to see the full example in action, check out the LiveKit GitHub repo here: RAG Example.
And hey, if you hit any bumps or have questions, just give me a shout—I’m here to help!
Sources: External data and RAG | LiveKit Docs | Handling RAG Delays in Voice Agents | LiveKit Docs | LiveKit | Recipes and examples for voice AI and more. | LiveKit Docs | rag/README.md | agent_extensions/agent_extensions/rag/handler.py