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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openlayer_guardrails-0.1.0.tar.gz.
File metadata
- Download URL: openlayer_guardrails-0.1.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43b9a0f42987dbdc85d53cbf0cd96e91ea8d33d51d2942287c42711134bf45aa
|
|
| MD5 |
cdd33f399662a34eae4c88cf1c4ff81a
|
|
| BLAKE2b-256 |
8990cbe155c1d936d4e924a348ed417d889a23dd773278fb2e9b7f18f26fca36
|
File details
Details for the file openlayer_guardrails-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openlayer_guardrails-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d65c170d1ce4232e706b8cda9bd3b4ba04bb5776c303d413ea01de59093ec1d
|
|
| MD5 |
6a6a320417d4acacf4fc90210f484bbf
|
|
| BLAKE2b-256 |
8629193f775659aa3633586a3a7fac16662ba3b4873c0b99f4c7c3840241212f
|