|
| 1 | +# Running Examples |
| 2 | + |
| 3 | +This page is wiki-ready and can be copied directly into the GitHub Wiki for the Python package if you want the examples guide to live there permanently. |
| 4 | + |
| 5 | +## Available Examples |
| 6 | + |
| 7 | +- `examples/python-fastapi` |
| 8 | + |
| 9 | +## FastAPI Gateway Example |
| 10 | + |
| 11 | +Path: [`examples/python-fastapi`](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/examples/python-fastapi) |
| 12 | + |
| 13 | +This example shows a Python gateway that applies Blackwall middleware before requests reach your LLM route, plus a small Streamlit dashboard for security visibility. |
| 14 | + |
| 15 | +### Run the API |
| 16 | + |
| 17 | +1. Create and activate a virtual environment. |
| 18 | +2. Install the example requirements. |
| 19 | +3. Copy environment values from [`.env.example`](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/examples/python-fastapi/.env.example). |
| 20 | +4. Start the API: |
| 21 | + |
| 22 | +```bash |
| 23 | +cd examples/python-fastapi |
| 24 | +python3 -m venv .venv |
| 25 | +source .venv/bin/activate |
| 26 | +pip install -r requirements.txt |
| 27 | +uvicorn main:app --reload |
| 28 | +``` |
| 29 | + |
| 30 | +The API will start on `http://127.0.0.1:8000`. |
| 31 | + |
| 32 | +### Run the Dashboard |
| 33 | + |
| 34 | +In a second terminal, from the same folder: |
| 35 | + |
| 36 | +```bash |
| 37 | +source .venv/bin/activate |
| 38 | +streamlit run streamlit_app.py |
| 39 | +``` |
| 40 | + |
| 41 | +### What It Demonstrates |
| 42 | + |
| 43 | +- `BlackwallFastAPIMiddleware` on `/chat` |
| 44 | +- request interception before model access |
| 45 | +- telemetry and audit-friendly event handling |
| 46 | +- a simple local dashboard for security operations |
| 47 | + |
| 48 | +### Main Files |
| 49 | + |
| 50 | +- [`main.py`](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/examples/python-fastapi/main.py) |
| 51 | +- [`streamlit_app.py`](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/examples/python-fastapi/streamlit_app.py) |
| 52 | +- [`dashboard_model.py`](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/examples/python-fastapi/dashboard_model.py) |
| 53 | +- [`requirements.txt`](/Users/vishnu/Documents/blackwall-llm-shield/blackwall-llm-shield-python/examples/python-fastapi/requirements.txt) |
| 54 | + |
| 55 | +## Suggested Wiki Placement |
| 56 | + |
| 57 | +If you want this to live in the GitHub Wiki instead of the repo tree, publish it as: |
| 58 | + |
| 59 | +- `Running Examples` |
| 60 | + |
| 61 | +and keep the in-repo copy as the source of truth for future edits. |
0 commit comments