Skip to content

damray/python_ai_proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Python AI Proxy with Palo Alto AIRS + Ollama + OpenWebUI

This project implements a secure reverse proxy in Python between OpenWebUI and Ollama, adding a real-time security layer using Palo Alto Networks AIRS.

The proxy intercepts every user prompt and model response to analyze it for malicious or sensitive content. If approved, the prompt or response is forwarded; otherwise, it is blocked with an appropriate explanation.


Features

  • Scans user prompts using AIRS before reaching the LLM
  • Scans model responses before returning to the user
  • Transparent fallback proxy for other Ollama API routes
  • Blocks toxic, malicious, or sensitive content
  • Fully dockerized for fast deployment
  • Compatible with OpenWebUI + Ollama models (e.g. LLaMA3)

Requirements

  • Docker & Docker Compose
  • A .env file with AIRS credentials:

PANW_X_PAN_TOKEN=your-token PANW_PROFILE_ID=your-profile-id PANW_PROFILE_NAME=your-profile-name


How to Use (Quickstart)

  1. Clone the repository: git clone https://github.com/your-user/python_ai_proxy.git cd python_ai_proxy

  2. Add a .env file with your AIRS credentials.

  3. Build & run the stack: docker-compose up --build

  4. Open OpenWebUI at: http://localhost:8080


Project Structure

. β”œβ”€β”€ airs.py # AIRS integration logic β”œβ”€β”€ main.py # FastAPI application β”œβ”€β”€ ollama.py # Helper for Ollama calls β”œβ”€β”€ Dockerfile # Python proxy container β”œβ”€β”€ docker-compose.yml # Full stack definition β”œβ”€β”€ requirements.txt # Python dependencies └── .env # Environment variables (ignored by git)


Example Blocked Response

{ "message": { "role": "assistant", "content": "β›” Response blocked by Palo Alto AIRS.\n\nCategory: sensitive_content\nSuggestion: Please reformulate your prompt." }, "done": true }


🧰 Tech Stack

  • Python 3.11
  • FastAPI + Uvicorn
  • aiohttp + requests
  • OpenWebUI frontend
  • Ollama for local models
  • Palo Alto Networks AIRS

πŸ“„ License

MIT License β€” see LICENSE for details.


πŸ™ Credits

  • Based on Palo Alto Networks AIRS API
  • Powered by Ollama + OpenWebUI

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published