feat: FastAPI surface, Streamlit dashboard, README screenshot#5
Merged
Conversation
Surface:
- `POST /v1/ingest` runs detect, redact, persist redaction map, chunk,
embed, and store. BM25 index is refreshed after every ingestion.
- `POST /v1/query` redacts the user query before embedding, runs the
hybrid retriever, generates a grounded answer, and re-runs the audit
over the answer. Response headers carry the audit verdict, the chunk
count, the faithfulness slot, and a request id.
- `GET /v1/audit/{document_id}` returns the persisted redaction map so
reviewers can see exactly what was caught at ingestion time.
- `GET /v1/stats` exposes aggregate detector counters.
- `GET /health` for the orchestrator.
Wiring:
- `dependencies.py` carries `AppState` (settings, detector, redactor,
pipeline, store, retriever, generator, auditor, stats) plus
`Annotated`-typed `*Dep` aliases so routes can be overridden by tests
with `app.dependency_overrides[...]`.
- `app.py` exposes `build_app(state)` for tests and `create_app()` for
production. The lifespan handler is where the heavy ML imports
finally happen: GLiNER, DeBERTa zero-shot validator, and the
sentence-transformers embedder are all loaded lazily.
- `StatsCollector` is thread-safe (lock-protected) in-memory.
Dashboard:
- Three Streamlit tabs: PII Protection Stats (donut, KPIs), Redaction
Explorer (paste text, see entities highlighted, diff before / after,
entity table), Eval Results (gauges against the golden corpus,
per-category table).
- `scripts/composite_dashboard.py` builds the 2x2 README banner from
per-tab screenshots; `docs/dashboard.png` is included.
- `scripts/demo.py` runs the end-to-end stack against a real Ollama
instance for local demos.
README image reference is restored now that the file exists.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /v1/ingest,POST /v1/query,GET /v1/audit/{document_id},GET /v1/stats,GET /healthX-Guardian-Pii-Audit/X-Guardian-Chunks-Used/X-Guardian-Request-IdheadersAppStatewith lazy ML backends (GLiNER, DeBERTa, sentence-transformers) and thread-safeStatsCollectorscripts/composite_dashboard.pybuilds the 2x2 README bannerdocs/dashboard.pngTest plan
uv run ruff check .cleanuv run pyright0 errors / 0 warningsuv run pytest tests/test_api.pyall green