Skip to main content

Guardrails that can be used to check inputs and outputs of functions and works well with Openlayer tracing.

Project description

Openlayer Guardrails

Open source guardrail implementations that work with Openlayer tracing.

Installation

pip install openlayer-guardrails[pii]

Usage

Standalone Usage

from openlayer_guardrails import PIIGuardrail

# Create guardrail
pii_guard = PIIGuardrail(
    block_entities={"CREDIT_CARD", "US_SSN"},
    redact_entities={"EMAIL_ADDRESS", "PHONE_NUMBER"}
)

# Check inputs manually
data = {"message": "My email is john@example.com and SSN is 123-45-6789"}
result = pii_guard.check_input(data)

if result.action.value == "block":
    print(f"Blocked: {result.reason}")
elif result.action.value == "modify":
    print(f"Modified data: {result.modified_data}")

With Openlayer Tracing

from openlayer_guardrails import PIIGuardrail
from openlayer.lib.tracing import trace

# Create guardrail
pii_guard = PIIGuardrail()

# Apply to traced functions
@trace(guardrails=[pii_guard])
def process_user_data(user_input: str):
    return f"Processed: {user_input}"

# PII is automatically detected and handled
result = process_user_data("My email is john@example.com")
# Output: "Processed: My email is [EMAIL-REDACTED]"

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

openlayer_guardrails-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

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

openlayer_guardrails-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file openlayer_guardrails-0.1.0.tar.gz.

File metadata

File hashes

Hashes for openlayer_guardrails-0.1.0.tar.gz
Algorithm Hash digest
SHA256 43b9a0f42987dbdc85d53cbf0cd96e91ea8d33d51d2942287c42711134bf45aa
MD5 cdd33f399662a34eae4c88cf1c4ff81a
BLAKE2b-256 8990cbe155c1d936d4e924a348ed417d889a23dd773278fb2e9b7f18f26fca36

See more details on using hashes here.

File details

Details for the file openlayer_guardrails-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openlayer_guardrails-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0d65c170d1ce4232e706b8cda9bd3b4ba04bb5776c303d413ea01de59093ec1d
MD5 6a6a320417d4acacf4fc90210f484bbf
BLAKE2b-256 8629193f775659aa3633586a3a7fac16662ba3b4873c0b99f4c7c3840241212f

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