This is a terminal-based Retrieval-Augmented Generation (RAG) demo that uses the Galileo SDK for observability.
- Interactive terminal UI with rich text formatting
- Simulated document retrieval with the
@log(span_type="retriever")decorator for Galileo observability - OpenAI GPT-4o integration for answering questions
- Python 3.8+
- OpenAI API key
- Galileo API key (optional, for observability)
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`- Install dependencies:
pip install -r requirements.txt- Set up environment variables by creating a
.envfile:
# Galileo Environment Variables
GALILEO_API_KEY=your-galileo-api-key # Your Galileo API key.
GALILEO_PROJECT=your-galileo-project-name # Your Galileo project name.
GALILEO_LOG_STREAM=your-galileo-log-stream # The name of the log stream you want to use for logging.
# Provide the console url below if you are using a custom deployment, and not using app.galileo.ai
# GALILEO_CONSOLE_URL=your-galileo-console-url # Optional if you are using a hosted version of Galileo
OPENAI_API_KEY=your-openai-api-key
Run the application:
python app.pyThe application will:
- Prompt you to enter a question
- Retrieve relevant documents (simulated in this demo)
- Generate an answer using OpenAI's GPT-4o
- Display the answer
- Ask if you want to continue with another question
To exit the application, type exit, quit, or q when prompted for a question, or press Ctrl+C at any time.
This demo uses the Galileo SDK for observability:
- The
@log(span_type="retriever")decorator is applied to theretrieve_documentsfunction - This allows Galileo to track and analyze the retrieval process
- The
span_type="retriever"parameter specifically identifies this as a retrieval operation in the observability pipeline
When Galileo logging is enabled (by setting the appropriate environment variables), you can view detailed metrics and traces in the Galileo console.
To implement a real retrieval system:
- Replace the simulated document list in
retrieve_documents()with actual vector database queries - Keep the
@log(span_type="retriever")decorator to maintain observability - Adjust the prompt in the
rag()function as needed for your specific use case