Metadata-Version: 2.5
Name: piitag
Version: 0.1.1
Summary: Python port of Desert Ant Labs' Redact on-device PII detector
License: # MIT License
        
        Copyright (c) 2026 Richard Hull
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE.md
License-File: NOTICE.md
Requires-Python: >=3.10
Requires-Dist: huggingface-hub>=0.20
Requires-Dist: numpy>=1.24
Requires-Dist: regex>=2024.1
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Provides-Extra: litert
Requires-Dist: ai-edge-litert; extra == 'litert'
Provides-Extra: tensorflow
Requires-Dist: tensorflow; extra == 'tensorflow'
Description-Content-Type: text/markdown

# piitag

Python port of Desert Ant Labs' Redact on-device PII detector.

The package is under active development. The implementation is being built in
stages described in [the implementation plan](docs/PLAN.md).

## Quick start

Install the package and one of the supported TFLite runtimes:

```sh
uv add piitag ai-edge-litert
```

The first detection downloads the pinned model assets into the Hugging Face
cache. You can also provide a directory containing the three model files:

```python
from piitag import Label, Options, Redact

redactor = Redact()
result = redactor.redaction("Email anna@example.com")
print(result.redacted_text)
print(result.restore(result.redacted_text))

only_email = redactor.redaction(
    "Email anna@example.com",
    Options(labels=frozenset({Label.EMAIL})),
)
```

The command-line interface accepts the same model cache by default:

```sh
uv run piitag "Email anna@example.com"
uv run piitag "Call +44 20 7946 0958" --labels PHONE --json
```

Use `--directory PATH` for an offline directory containing
`redact_tokenizer.bin`, `labels.json`, and `redact.tflite`.

## Development setup

Requirements:

- Python 3.10 or newer
- [uv](https://docs.astral.sh/uv/)

Create an isolated environment and install the development dependencies:

```sh
uv venv
source .venv/bin/activate
uv sync --extra dev --extra litert
```

Use `--extra tensorflow` instead of `--extra litert` when TensorFlow is the
preferred TFLite runtime.

## Build, test, and check

```sh
uv run pytest
uv run ruff check src/ tests/ scripts/
uv run ruff format --check src/ tests/ scripts/
uv run mypy src/
uv run python -m build
uv run twine check dist/*
```

Model weights and taxonomy assets are not bundled with the package. See
[NOTICE.md](NOTICE.md) for the applicable model license.

## Release

Releases use Conventional Commits on `main` with
`python-semantic-release`. The release workflow updates the package version,
synchronizes `uv.lock`, updates [CHANGELOG.md](CHANGELOG.md), creates a tag
and GitHub release, and publishes the wheel and source archive to PyPI.

PyPI publishing uses Trusted Publishing. Configure the PyPI project publisher
for this repository, workflow, and the `pypi` environment before publishing.

- `fix:` creates a patch release.
- `feat:` creates a minor release.
- `BREAKING CHANGE:` or a `!` after the commit type creates a major release.

Preview the next release locally without changing files:

```sh
uv run semantic-release --noop version
```

## License

The `piitag` wrapper code is available under the MIT license. Model weights
and taxonomy assets are not bundled with the package. Runtime downloads from
the `desert-ant-labs/redact` Hugging Face repository at revision `v0.4.0` are
subject to the Desert Ant Labs Source-Available License. See
[NOTICE.md](NOTICE.md) before using those assets commercially.

## AI-generated code disclaimer

This codebase was generated with assistance from **GitHub Copilot**. The
exact underlying model identifier used for this session is not exposed by the
available session metadata, so no more specific model name is claimed here.
Review and test all generated code before using it in production.