PO
pooyaphoenix/RA3G-Agent
Local RAG system with a built-in governance agent that filters sensitive or restricted information with separated agent logging systems to keep privacy and security
Policy-Aware RAG Multi-Agent AI System
๐ Quick Start
Option 1: Docker (Recommended)
git clone https://github.com/pooyaphoenix/RA3G-Agent.git
cd RA3G-Agent
docker compose up --buildOption 2: Local Installation
git clone https://github.com/pooyaphoenix/RA3G-Agent.git
cd RA3G-Agent
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python ra3g.py --api-port 8010 --ui-port 8501Access the application:
- ๐ Web UI: http://localhost:8501
- ๐ก API Docs: http://localhost:8010/docs
- ๐ Health Check: http://localhost:8010/health
โจ Features
- ๐ Local RAG System - Query your documents without external APIs
- ๐ก๏ธ Governance Agent - Automatically filters sensitive information
- ๐ค Multi-Agent Architecture - Retriever, Reasoning, and Governance agents
- ๐พ Session Memory - Remembers previous queries and context
- ๐ Real-time Logs - Monitor agent activity with live log streaming
- ๐ PDF Document Upload - Automatic PDF upload and vector store building
- ๐จ Streamlit UI - Beautiful web interface for easy interaction
- ๐ REST API - Full programmatic access via FastAPI
- โ๏ธ Fully Customizable - Easy configuration via
config.yml
๐ฌ Demo
๐๏ธ Architecture
Agent Flow:
- Retriever Agent - Finds relevant passages from your corpus
- Reasoning Agent - Generates answers using Ollama LLM
- Governance Agent - Validates and filters responses based on policies
๐ Usage Examples
Web UI
- Open http://localhost:8501
- Navigate to the Chat tab
- Type your question and get instant answers
API Request
curl -X POST 'http://localhost:8010/query' \
-H 'Content-Type: application/json' \
-H 'session-id: my-session' \
-d '{
"query": "What are the benefits of regular hand washing?",
"top_k": 5
}'API Response
{
"query": "What are the benefits of regular hand washing?",
"answer": "Preventing the spread of infections is one of the simplest ways.",
"governance": {
"approved": true,
"reason": "approved"
},
"trace": [
{
"index": 0,
"note": "relevant passage about benefits of hand washing"
}
],
"retrieved": [
{
"id": "corpus_medical_general.txt#p0",
"text": "...",
"source": "corpus_medical_general.txt",
"score": 0.51
}
],
"confidence": 0.512,
"session_id": "my-session"
}Python Client Example
import requests
response = requests.post(
'http://localhost:8010/query',
headers={'session-id': 'my-session'},
json={'query': 'What is machine learning?', 'top_k': 5}
)
print(response.json()['answer'])๐ API Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST |
/query |
Ask a question through RAG |
GET |
/health |
Health check for all agents |
GET |
/health/{agent} |
Health check for specific agent |
GET |
/trace |
Get session query history |
DELETE |
/memory/clear |
Clear session memory |
GET |
/docs |
Interactive Swagger UI |
GET |
/logs/stream/{log_type} |
Stream logs in real-time (SSE) |
Try it live: http://localhost:8010/docs
๐ก๏ธ Governance Rules
The governance agent automatically blocks or approves queries based on:
โ Blocked:
- Personal names, phone numbers, addresses
- Medical records and patient data
- Confidential corporate information
- Banned phrases (configurable in
config.yml)
โ Allowed:
- General medical, scientific questions
- Educational content
- Public information
๐ Adding Documents
- Place your documents in
data/corpus/directory (.txtor.mdfiles) - Automatic indexing - The system builds the FAISS index on startup
- Manual indexing (optional):
python indexer.py --corpus data/corpus
Configuration: Edit config.yml to customize corpus directory and indexing behavior.
โ๏ธ Configuration
All settings are in config.yml:
# Ollama Configuration
OLLAMA_URL: http://localhost:11434/api/generate
OLLAMA_MODEL: qwen2.5:7b-instruct
# Embedding Model
EMBED_MODEL: all-MiniLM-L6-v2
# Confidence Thresholds
THRESHOLDS:
retriever: 0.72
reasoner: 0.81
# Auto-build index on startup
AUTO_BUILD_FAISS: true
CORPUS_DIR: data/corpus
# Banned phrases for governance
BANNED_PHRASES:
- diagnosis
- prescription
- classified
- confidential๐งช Testing
# Health check
curl http://localhost:8010/health
# Test query
curl -X POST http://localhost:8010/query \
-H 'Content-Type: application/json' \
-H 'session-id: test' \
-d '{"query": "Hello", "top_k": 3}'๐ Requirements
- Python 3.8+
- Ollama (for LLM inference)
- Docker (optional, for containerized deployment)
See requirements.txt for Python dependencies.
๐ค Contributing
See CONTRIBUTING.md for guidelines.
๐ง Contact
๐ License
See LICENSE file for details.
On this page
Languages
Python98.9%Dockerfile1.1%
MIT License
Created October 17, 2025
Updated February 17, 2026