|
| 1 | +# Changelog |
| 2 | + |
| 3 | +All notable changes to this project will be documented in this file. |
| 4 | + |
| 5 | +The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), |
| 6 | +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
| 7 | + |
| 8 | +--- |
| 9 | + |
| 10 | +## [Unreleased] |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## [2.0.0] — 2026-02-24 |
| 15 | + |
| 16 | +### Breaking Changes |
| 17 | + |
| 18 | +- **Architecture change**: local GPT-2 generator completely removed; the pipeline |
| 19 | + is now a pure **async HTTP proxy** to a remote LLM backend (Ollama, |
| 20 | + OpenAI-compatible, or custom). |
| 21 | +- `SafetyConfig` — removed fields: `llm_model_name`, `max_new_tokens`, |
| 22 | + `temperature`, `top_p`, `batch_size`, `max_cache_size`. These are now |
| 23 | + configured via `LLMBackendConfig` / environment variables. |
| 24 | +- `SafetyPipeline.process()` — `generate=` keyword argument removed. |
| 25 | + `process()` is now input-only (sync, no LLM call). |
| 26 | + |
| 27 | +### Added |
| 28 | + |
| 29 | +- `LLMBackendConfig` dataclass with `from_env()` class method — supports |
| 30 | + `ollama`, `openai`, and `custom` backend types. |
| 31 | +- `ExternalLLMClient` — async `httpx`-based HTTP client with exponential-backoff |
| 32 | + retry (does not retry on 4xx errors). |
| 33 | +- `SafetyPipeline.async_process()` — full async pipeline: |
| 34 | + input safety checks → remote LLM → output safety checks. |
| 35 | +- `SafetyPipeline.async_close()` — graceful shutdown of the underlying |
| 36 | + `httpx.AsyncClient`. |
| 37 | +- `SafetyPipeline.backend_health()` — async probe of the remote LLM endpoint. |
| 38 | +- `RejectionReason.BACKEND_UNAVAILABLE` and `RejectionReason.INPUT_TOO_LONG`. |
| 39 | +- `SafetyConfig.max_prompt_length` (default 10 000 characters) — input length guard. |
| 40 | +- `GET /health/backend` API endpoint — probes the remote LLM reachability. |
| 41 | +- `POST /api/v1/statistics/reset` now requires `X-API-Key: <ADMIN_API_KEY>` header. |
| 42 | +- Full async test suite: 74 tests using `pytest-asyncio` and `respx` for httpx mocking. |
| 43 | +- `pyproject.toml`, `LICENSE`, `.gitignore`, `.env.example`, `CONTRIBUTING.md`, |
| 44 | + `CHANGELOG.md`, GitHub Actions CI workflows. |
| 45 | + |
| 46 | +### Changed |
| 47 | + |
| 48 | +- CPU-bound PyTorch/spaCy inference offloaded to a thread-pool executor so the |
| 49 | + asyncio event loop stays unblocked. |
| 50 | +- `SafetyReport` check-passed flags changed to `Optional[bool]` — `None` means |
| 51 | + the check was not run (disabled or not reached), preventing false "passed" signals. |
| 52 | +- `get_statistics()` now returns a `copy.deepcopy()` to prevent callers from |
| 53 | + mutating live counters. |
| 54 | +- `device` in `SafetyConfig` now uses `field(default_factory=...)` to detect |
| 55 | + CUDA safely at construction time. |
| 56 | +- Safe-context regex no longer bypasses all downstream layers — it now defers to |
| 57 | + the semantic classifier for a final verdict. |
| 58 | +- `SemanticSafetyClassifier` correctly handles `unitary/toxic-bert`'s multi-label |
| 59 | + output (sigmoid + `probs.max()`) instead of binary softmax. |
| 60 | +- CORS: `allow_credentials=False`; origins opt-in via `ALLOWED_ORIGINS` env var. |
| 61 | +- FastAPI `@app.on_event` replaced with `@asynccontextmanager lifespan`. |
| 62 | + |
| 63 | +### Fixed |
| 64 | + |
| 65 | +- `_has_prohibited_entities` now checks both NER labels and plain text, fixing |
| 66 | + false-negatives for entities spaCy did not label. |
| 67 | +- `_has_harmful_instruction_pattern` uses dependency-tree traversal instead of |
| 68 | + a flat token scan, reducing false-positives. |
| 69 | +- `add_custom_filter` now properly raises on duplicate filter names. |
| 70 | +- `subprocess.run` in model download helper uses `sys.executable` so the correct |
| 71 | + Python is invoked inside virtual environments. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## [1.0.0] — 2024-01-01 |
| 76 | + |
| 77 | +### Added |
| 78 | + |
| 79 | +- Initial release: multi-layer LLM safety pipeline with local GPT-2 generation. |
| 80 | +- `TokenLevelFilter`, `RuleEngineFilter`, `SemanticSafetyClassifier`, `SafeLLMGenerator`. |
| 81 | +- `SafetyPipeline.process(prompt, generate=True/False)`. |
| 82 | +- FastAPI server with `/check`, `/generate`, `/statistics` endpoints. |
| 83 | +- Docker + docker-compose support. |
| 84 | + |
| 85 | +--- |
| 86 | + |
| 87 | +[Unreleased]: https://github.com/SahilChachra/LLM-Safety-Middleware/compare/v2.0.0...HEAD |
| 88 | +[2.0.0]: https://github.com/SahilChachra/LLM-Safety-Middleware/compare/v1.0.0...v2.0.0 |
| 89 | +[1.0.0]: https://github.com/SahilChachra/LLM-Safety-Middleware/releases/tag/v1.0.0 |
0 commit comments