This project establishes an enterprise-grade "LLM-as-a-Judge" safety layer. Operating as asynchronous middleware between autonomous AI agents and end-users, it intercepts, evaluates, and deterministically routes generated outputs to prevent policy violations, prompt injections, and off-topic domain drift.
Large Language Models exhibit structural vulnerabilities when tasked with simultaneous generation and self-critique. This architecture deploys a decoupled, secondary "Judge" model enforcing strict validation matrices before output delivery.
- Python 3.10+ (Asynchronous execution topology)
- Ollama Cloud/Local: Core inference engine for both Primary Generator and Secondary Judge models.
- Pydantic: Strict configuration and schema enforcement.
- Clone the repository and establish an isolated virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
- Clone the repository.
- Create a virtual environment:
python -m venv venv - Activate the environment.
- Install dependencies:
pip install -r requirements.txt - Create a
.envfile and add your API key:OLLAMA_API_KEY=your_api_key_here
Run the guardrail proxy:
python guardrail.py