Policy-Aware RAG Multi-Agent AI System
git clone https://github.com/pooyaphoenix/RA3G-Agent.git
cd RA3G-Agent
docker compose up --buildgit 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
- π 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
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
- Open http://localhost:8501
- Navigate to the Chat tab
- Type your question and get instant answers
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
}'{
"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"
}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'])| 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
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
- 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.
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# 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}'- Python 3.8+
- Ollama (for LLM inference)
- Docker (optional, for containerized deployment)
See requirements.txt for Python dependencies.
See CONTRIBUTING.md for guidelines.
See LICENSE file for details.

