Metadata-Version: 2.5
Name: paxmod-guard
Version: 0.1.0
Summary: Local safety classifier for AI companions, chatbots and kids' game chat: self-harm, grooming, sexual content, jailbreaks and more, on your own CPU in milliseconds.
Author: Paxmod
License-Expression: Apache-2.0
Keywords: ai-safety,chatbot,child-safety,companion,guardrails,llm,moderation,onnx
Requires-Python: >=3.9
Requires-Dist: numpy>=1.24
Requires-Dist: onnxruntime>=1.17
Requires-Dist: tokenizers>=0.15
Description-Content-Type: text/markdown

# paxmod-guard

Safety checks for AI companions, chatbots and kids' game chat, running on your own CPU. No API key, no network calls
after the first model download, and no message ever leaves your server. The Python twin of the
[`@paxmod/guard`](https://www.npmjs.com/package/@paxmod/guard) npm package: same model, same scores.

```bash
pip install paxmod-guard
```

```python
from paxmod_guard import Guard

guard = Guard()  # downloads the model once (about 220 MB) to ~/.cache/paxmod-guard

# 1. Check what the user sent before your model sees it
r = guard.check_input(user_message)
if r.crisis_reply:
    return r.crisis_reply          # self-harm risk: answer with crisis support, not the persona
if "jailbreak" in r.labels:
    return "Let's keep things friendly."

# 2. Check what your bot wrote before the user sees it
reply = llm.generate(user_message)
if guard.check_output(reply).flagged:
    return regenerate_or_refuse()
```

Needs about 1 GB of memory: run it in a container or on a server, not in small serverless functions.

Game or community chat, with the messages before it, or a whole conversation (grooming and other patterns that no
single message shows):

```python
guard.check_chat("wanna add me on snap", context=[{"role": "player", "speaker": "B", "text": "im 12"}])
guard.check_conversation([{"role": "player", "speaker": "A", "text": "..."}, ...])
```

Each result has `flagged`, `labels`, `scores` (every label, 0 to 1) and `latency_ms`. Signal labels (grooming tactics,
distress, swearing, age questions, romance) are always scored but only flag when enabled:
`Guard(enable=["secrecy", "risk_check"])`. Thresholds can be overridden per label: `Guard(thresholds={"sexual": 0.7})`.

Licence: Apache-2.0. Model card and labels: https://huggingface.co/paxmod/guard
