red-computer-69679
07/07/2025, 7:52 AMtall-airline-16756
07/07/2025, 7:52 AMtall-airline-16756
07/07/2025, 7:52 AMred-computer-69679
07/07/2025, 7:55 AMtall-airline-16756
07/07/2025, 7:55 AM# Check if storage already exists
PERSIST_DIR = THIS_DIR / "retrieval-engine-storage"
if not PERSIST_DIR.exists():
# Load the documents and create the index
documents = SimpleDirectoryReader(THIS_DIR / "data").load_data()
index = VectorStoreIndex.from_documents(documents)
# Store it for later
index.storage_context.persist(persist_dir=PERSIST_DIR)
else:
# Load the existing index
storage_context = StorageContext.from_defaults(persist_dir=PERSIST_DIR)
index = load_index_from_storage(storage_context)
2. Define the Agent Class: This is where you'll set up your agent with all its cool components. It's like assembling your dream team of AI capabilities:
class RetrievalAgent(Agent):
def __init__(self, index: VectorStoreIndex):
super().__init__(
instructions="You are a voice assistant created by LiveKit...",
vad=silero.VAD.load(),
stt=deepgram.STT(),
llm=openai.LLM(),
tts=openai.TTS(),
)
self.index = index
3. Reuse the Configuration: Now comes the magic—you can easily bring back your agent's setup without rebuilding everything from scratch. This saves you time and computing power! Need more details or have a specific scenario in mind? I'm here to help you navigate this AI configuration journey. Just give me a shout! 😊 Sources: GitHub::livekit::agents | examples/voice_agents/llamaindex-rag/query_engine...red-computer-69679
07/07/2025, 7:58 AMtall-airline-16756
07/07/2025, 7:58 AMred-computer-69679
07/07/2025, 8:00 AMtall-airline-16756
07/07/2025, 8:01 AM