A Retrieval-Augmented Generation (RAG) application that allows you to query a knowledge base of Game of Thrones lore using a "Maester" persona. The application uses Google's Gemini API for embeddings and text generation.
- Vector Database: Indexes text files related to Game of Thrones history.
- Maester Persona: Answers questions in the style of a Citadel Archmaester.
- Terminal UI: A text-based user interface powered by
textualfor an immersive experience.
- Clone the repository (if applicable).
- Create a virtual environment:
python3 -m venv venv source venv/bin/activate - Install dependencies:
(Note: You may need to create a
pip install -r requirements.txt
requirements.txtbased on the imports in the scripts if one is not provided. Key packages includelangchain,langchain-chroma,langchain-google-genai,textual,python-dotenv). - Set up environment variables:
Create a
.envfile in the root directory and add your Gemini API key:GEMINI_API_KEY=your_api_key_here
Before asking questions, you need to index the data. The data/ folder contains the text files to be indexed.
Open maester_brain.py and uncomment the line oracle.build_library() in the __main__ block, or run the build command if you've set up a CLI argument.
Run the script:
python maester_brain.pyThis creates the citadel_db directory containing the vector store.
Launch the terminal UI to interact with the Maester:
python archmaester_ui.pyAPI Rate Limits (429 Resource Exhausted)
This application uses the embedding-001 model from Google. On the free tier, you may encounter RESOURCE_EXHAUSTED errors when indexing a large number of files or making frequent requests.
Solutions:
- Wait and Retry: The application includes basic pauses, but you may need to wait for quotas to reset.
- Upgrade Plan: Using a paid tier for the Gemini API significantly increases the rate limits, allowing for faster indexing and more frequent queries.
- Reduce Data: Try indexing fewer files at a time.