Skip to main content

GRID Safety layer and Cognitive Privacy Shield: real-time safety enforcement, PII detection, masking, and compliance presets (GDPR, HIPAA, PCI-DSS) for AI inference.

Project description

grid-safety

GRID Safety layer and Cognitive Privacy Shield: real-time safety enforcement, PII detection, masking, and compliance presets (GDPR, HIPAA, PCI-DSS) for AI inference.

Install

pip install grid-safety

Minimal usage

Cognitive Privacy Shield (library)

from safety.privacy import get_privacy_engine, PrivacyPreset, AsyncPIIDetector

# Get engine with a compliance preset
engine = get_privacy_engine(preset=PrivacyPreset.BALANCED)

# Detect PII
detections = await engine.detect("Contact me at user@example.com")

# Process (detect + mask/block/ask)
result = await engine.process("My SSN is 123-45-6789")
print(result.processed_text)  # Masked or blocked per preset
print(result.detections)

Run the Safety API server

safety-api

Runs the FastAPI app (auth, rate limiting, pre-check, Privacy Shield middleware, inference queue). Configure via environment variables:

Variable Default Description
SAFETY_API_HOST 0.0.0.0 Bind host
SAFETY_API_PORT 8000 Bind port
SAFETY_API_RELOAD (off) Set to 1, true, or yes to enable reload

Endpoints include:

  • POST /infer — Submit inference (enqueued to Redis)
  • POST /privacy/detect — Detect PII in text
  • POST /privacy/mask — Mask or block PII
  • POST /privacy/batch — Batch PII detection/masking (up to 100 texts)
  • GET /health, GET /metrics

Set SAFETY_DEGRADED_MODE=true to run without Redis (e.g. for tests).

Architecture

The Cognitive Privacy Shield is GRID's core safety and privacy API. For pipeline details, integration points, and key files, see:

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grid_safety-1.0.0.tar.gz (127.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grid_safety-1.0.0-py3-none-any.whl (172.7 kB view details)

Uploaded Python 3

File details

Details for the file grid_safety-1.0.0.tar.gz.

File metadata

  • Download URL: grid_safety-1.0.0.tar.gz
  • Upload date:
  • Size: 127.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for grid_safety-1.0.0.tar.gz
Algorithm Hash digest
SHA256 29eba5c787b0a9d875968c7c1781e81e3d2c44b9de11486bd6408a1818ac2072
MD5 89a0737523bed1b07ab25ab6d4c78523
BLAKE2b-256 e49aa073d7a682a6e66c329cbff01616786da01154b6a865b327550dc71c3f88

See more details on using hashes here.

File details

Details for the file grid_safety-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: grid_safety-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 172.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for grid_safety-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cea2555622197f86cc6104dd7523ca4dbafb89fdb13ba5a531a49dd6620ba554
MD5 e6d1e3d6e6fb276a77db1c5d366c6c40
BLAKE2b-256 a6fbe7dd29080f739e76b2333970b70dae1ab6db30a8361aee94a43a0381bdd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page