A simple Retrieval-Augmented Generation (RAG) AI agent using Pydantic AI and Supabase with pgvector for document storage and retrieval.
- Document ingestion pipeline for TXT and PDF files
- Vector embeddings using OpenAI
- Document storage in Supabase with pgvector
- Pydantic AI agent with knowledge base search capabilities
- Streamlit UI for document uploads and agent interaction
foundational-rag-agent/
├── database/
│ └── setup.py # Database setup and connection utilities
├── document_processing/
│ ├── __init__.py
│ ├── chunker.py # Text chunking functionality
│ ├── embeddings.py # Embeddings generation with OpenAI
│ ├── ingestion.py # Document ingestion pipeline
│ └── processors.py # TXT and PDF processing
├── agent/
│ ├── __init__.py
│ ├── agent.py # Main agent definition
│ ├── prompts.py # System prompts
│ └── tools.py # Knowledge base search tool
├── ui/
│ └── app.py # Streamlit application
├── tests/
│ ├── test_chunker.py
│ ├── test_embeddings.py
│ ├── test_ingestion.py
│ ├── test_processors.py
│ └── test_agent.py
├── .env.example # Example environment variables
├── requirements.txt # Project dependencies
├── PLANNING.md # Project planning document
├── TASK.md # Task tracking
└── README.md # Project documentation
- Clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate - Install dependencies:
pip install -r requirements.txt - Copy
.env.exampleto.envand fill in your API keys and configuration - Run the Streamlit application:
streamlit run ui/app.py - Run the SQL in
rag-example.sqlto create the table and matching function for RAG
- Upload documents (TXT or PDF) through the Streamlit UI
- Ask questions to the AI agent
- View responses with source attribution
To deploy this application on Render, build the provided Dockerfile and set th
e service command to:
streamlit run ui/app.py --server.port $PORT --server.address 0.0.0.0Render automatically injects the PORT environment variable which the
container uses to expose the Streamlit UI.
- Python 3.11+
- Pydantic AI
- Supabase
- OpenAI
- PyPDF2
- Streamlit
MIT