claimcheck-rules / python /README.md
NagaYu's picture
Add the Python reference implementation (Gradio UI + REST API) for self-hosting
0675e3e verified
|
Raw
History Blame Contribute Delete
1.76 kB
# ClaimCheck — Python implementation
The reference implementation. Same rules as the JavaScript port that powers the
[Space](https://huggingface.co/spaces/NagaYu/ClaimCheck), verified at **100% behavioural parity**
across all 158 cases of [`NagaYu/claimcheck-eval`](https://huggingface.co/datasets/NagaYu/claimcheck-eval).
Use this when you want a **server-side API** rather than a browser page: a Gradio UI with seven REST
endpoints, an in-memory observability dashboard (per-model/per-prompt-version comparison, latency
percentiles, savings), and a false-positive audit tab.
```bash
pip install -r requirements.txt
python app.py # http://127.0.0.1:7860
```
```python
from gradio_client import Client
client = Client("http://127.0.0.1:7860/")
result, highlighted, summary = client.predict(
answer="Operating margin was 15%.",
context="Revenue was 12,000 million and operating profit 1,800 million.",
system_prompt="", user_input="", schema_json="",
policy_json='{"enable_entity": false}',
tags_json='{"model": "my-model", "prompt_version": "v1"}',
api_name="/verify",
)
print(result["verdict"], result["grounding_score"], result["coverage"])
```
Endpoints: `/verify`, `/retry_advice`, `/stats`, `/structure`, `/health`, `/audit_refresh`, `/audit_mark`.
`deploy.md` is a step-by-step deployment guide (in Japanese) including a staged rollout plan.
> **Note on Hugging Face Spaces:** Gradio Spaces now require a PRO subscription on `cpu-basic`.
> Only static Spaces are free, which is why the hosted demo is the JavaScript port. This Python
> version is for self-hosting anywhere you like.
Verification itself uses **only the standard library** — `gradio` and `pandas` are for the UI and the
dashboard. Apache-2.0.