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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

grid_safety-1.0.2-py3-none-any.whl (244.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: grid_safety-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 244.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for grid_safety-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2c3dfd3254167eb3a38609d65c71f19ccb123035747a127a4ba83b2f0b6e0576
MD5 ef348192f157aadd38585f62beabcf97
BLAKE2b-256 1c38dce1510c24c73cbd33d09b1992706dd041ac948fd5021dbcc5a1ebbdfb56

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