|
| 1 | +# LLM Router Web |
| 2 | + |
| 3 | +Web interface for managing LLM Router configurations and text anonymization. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +`llm_router_web` provides two Flask-based web applications: |
| 8 | + |
| 9 | +1. **Config Manager** – Manage LLM Router model configurations with multi-user support |
| 10 | +2. **Anonymizer** – Web UI for text anonymization and chat with anonymization |
| 11 | + |
| 12 | +## Features |
| 13 | + |
| 14 | +### Config Manager (`app_cfg_manager`) |
| 15 | + |
| 16 | +- **User Management**: Admin panel, authentication, role-based access |
| 17 | +- **Project Management**: Organize configurations into projects |
| 18 | +- **Model Configuration**: |
| 19 | + - Create, edit, import/export configurations (JSON) |
| 20 | + - Manage models across families (Google, OpenAI, Qwen) |
| 21 | + - Configure providers (API hosts, tokens, weights, input sizes) |
| 22 | + - Version control with restore capability |
| 23 | +- **Active Model Selection**: Choose which models to activate |
| 24 | + |
| 25 | +### Anonymizer (`app_anonymizer`) |
| 26 | + |
| 27 | +- **Text Anonymization**: Multiple algorithms (fast, GenAI, PrivMasker) |
| 28 | +- **Chat Interface**: Interactive chat with optional anonymization |
| 29 | +- **Model Selection**: Browse and select available LLM models |
| 30 | +- **Real-time Processing**: Direct integration with LLM Router API |
| 31 | + |
| 32 | +## Installation |
| 33 | + |
| 34 | +```bash |
| 35 | +pip install -r requirements.txt |
| 36 | +``` |
| 37 | + |
| 38 | +### Requirements |
| 39 | + |
| 40 | +- Flask |
| 41 | +- Flask-SQLAlchemy |
| 42 | +- Gunicorn |
| 43 | + |
| 44 | +## Usage |
| 45 | + |
| 46 | +### Config Manager |
| 47 | + |
| 48 | +**Run with Gunicorn (recommended):** |
| 49 | + |
| 50 | +```bash |
| 51 | +./run-configs-manager.sh |
| 52 | +``` |
| 53 | + |
| 54 | +**Run directly:** |
| 55 | + |
| 56 | +```bash |
| 57 | +python app_cfg_manager.py |
| 58 | +``` |
| 59 | + |
| 60 | +**Configuration (environment variables):** |
| 61 | + |
| 62 | +- `LLM_ROUTER_WEB_CFG_HOST` – Bind address (default: `0.0.0.0`) |
| 63 | +- `LLM_ROUTER_WEB_CFG_PORT` – Port (default: `8081`) |
| 64 | +- `LLM_ROUTER_WEB_CFG_DEBUG` – Debug mode (default: `true`) |
| 65 | + |
| 66 | +**First-time setup:** |
| 67 | + |
| 68 | +1. Access the web interface |
| 69 | +2. Create initial admin account via setup page |
| 70 | +3. Log in and start managing configurations |
| 71 | + |
| 72 | +**Default URL:** http://localhost:8081 |
| 73 | + |
| 74 | +### Anonymizer |
| 75 | + |
| 76 | +**Run with Gunicorn (recommended):** |
| 77 | + |
| 78 | +```bash |
| 79 | +./run-anonymizer.sh |
| 80 | +``` |
| 81 | + |
| 82 | +**Run directly:** |
| 83 | + |
| 84 | +```bash |
| 85 | +python app_anonymizer.py |
| 86 | +``` |
| 87 | + |
| 88 | +**Configuration (environment variables):** |
| 89 | + |
| 90 | +- `LLM_ROUTER_WEB_ANO_HOST` – Bind address (default: `0.0.0.0`) |
| 91 | +- `LLM_ROUTER_WEB_ANO_PORT` – Port (default: `8082`) |
| 92 | +- `LLM_ROUTER_WEB_ANO_DEBUG` – Debug mode (default: `true`) |
| 93 | +- `LLM_ROUTER_HOST` – LLM Router API endpoint (default: `http://192.168.100.65:8080`) |
| 94 | +- `LLM_ROUTER_GENAI_MODEL_ANONYMISATION` – Model for GenAI anonymization (default: `gtp-oss:120b`) |
| 95 | + |
| 96 | +**Default URL:** http://localhost:8082/anonymize |
| 97 | + |
| 98 | +## API Endpoints |
| 99 | + |
| 100 | +### Config Manager |
| 101 | + |
| 102 | +| Endpoint | Method | Description | |
| 103 | +|----------|--------|-------------| |
| 104 | +| `/` | GET | Configuration list (home) | |
| 105 | +| `/login` | GET/POST | User login | |
| 106 | +| `/logout` | GET | User logout | |
| 107 | +| `/setup` | GET/POST | Initial admin setup | |
| 108 | +| `/admin/users` | GET/POST | User management (admin) | |
| 109 | +| `/projects` | GET/POST | Project management | |
| 110 | +| `/configs` | GET | List configurations | |
| 111 | +| `/configs/new` | GET/POST | Create configuration | |
| 112 | +| `/configs/import` | GET/POST | Import JSON configuration | |
| 113 | +| `/configs/<id>` | GET | View configuration | |
| 114 | +| `/configs/<id>/edit` | GET/POST | Edit configuration | |
| 115 | +| `/configs/<id>/export` | GET | Export configuration (JSON) | |
| 116 | +| `/configs/<id>/activate` | POST | Activate configuration | |
| 117 | +| `/configs/<id>/delete` | POST | Delete configuration | |
| 118 | +| `/configs/<id>/models/add` | POST | Add model | |
| 119 | +| `/models/<id>/delete` | POST | Delete model | |
| 120 | +| `/models/<id>/providers/add` | POST | Add provider | |
| 121 | +| `/providers/<id>/update` | POST | Update provider | |
| 122 | +| `/providers/<id>/delete` | POST | Delete provider | |
| 123 | + |
| 124 | +### Anonymizer |
| 125 | + |
| 126 | +| Endpoint | Method | Description | |
| 127 | +|----------|--------|-------------| |
| 128 | +| `/anonymize/` | GET | Anonymization form | |
| 129 | +| `/anonymize/` | POST | Process text anonymization | |
| 130 | +| `/anonymize/chat` | GET | Chat interface | |
| 131 | +| `/anonymize/chat/message` | POST | Send chat message | |
| 132 | +| `/anonymize/models` | GET | List available models | |
| 133 | + |
| 134 | +## Project Structure |
| 135 | + |
| 136 | +``` |
| 137 | +llm_router_web/ |
| 138 | +├── app_anonymizer.py # Anonymizer Flask app entry point |
| 139 | +├── app_cfg_manager.py # Config Manager Flask app entry point |
| 140 | +├── run-anonymizer.sh # Anonymizer startup script (gunicorn) |
| 141 | +├── run-configs-manager.sh # Config Manager startup script (gunicorn) |
| 142 | +├── requirements.txt # Python dependencies |
| 143 | +├── instance/ |
| 144 | +│ └── configs.db # SQLite database (auto-created) |
| 145 | +└── web/ |
| 146 | + ├── anonymizer/ # Anonymizer blueprint & routes |
| 147 | + ├── configs_manager/ # Config Manager blueprint, models & routes |
| 148 | + ├── templates/ # HTML templates |
| 149 | + └── static/ # Static assets (CSS, JS) |
| 150 | +``` |
| 151 | + |
| 152 | +## Database |
| 153 | + |
| 154 | +Config Manager uses SQLite with SQLAlchemy ORM: |
| 155 | + |
| 156 | +- **Models**: `User`, `Project`, `Config`, `Model`, `Provider`, `ActiveModel`, `ConfigVersion` |
| 157 | +- **Location**: `instance/configs.db` (auto-created on first run) |
| 158 | +- **Version Control**: Automatic configuration snapshots on changes |
| 159 | + |
| 160 | +## Security |
| 161 | + |
| 162 | +- Password hashing via Werkzeug |
| 163 | +- Session-based authentication |
| 164 | +- Role-based access control (admin/user) |
| 165 | +- User account blocking capability |
| 166 | +- Per-user project isolation |
| 167 | + |
| 168 | +## Notes |
| 169 | + |
| 170 | +- Config Manager requires initial admin setup on first run |
| 171 | +- Anonymizer requires a running LLM Router instance |
| 172 | +- Both apps run independently on different ports |
| 173 | +- Configurations are stored in SQLite database (Config Manager only) |
| 174 | +- All configuration changes are versioned and can be restored |
0 commit comments