Tano Shield
A Python client library for interacting with the Tano Shield AI security services.
Installation
pip install tano-shield
# or
poetry add tano-shield
Features
- AI Issue Detector: Protect your AI applications from harmful inputs and outputs
- PII Redaction: Detect and redact personally identifiable information
Usage
Quick Start
from tano_shield import TanoShield
# Initialize the client with your API key
tano_shield = TanoShield(api_key="your-api-key")
# Use the services
def example():
try:
# Check user input with the Issue Detector
firewall_result = tano_shield.firewall.check_input(
system_prompt="You are a helpful AI assistant",
user_input="Tell me about AI security",
response="I can provide information about AI security...",
event_id="conversation-12345",
security_checks=[
"sycophancy",
"faithfulness",
"harmfulness",
"implausible_output",
"information_disclosure",
"jailbreak"
]
)
print('Issue Detector check result:', firewall_result)
# Redact PII from text
pii_result = tano_shield.pii.redact_text(
text='My email is john.doe@example.com and my phone is 555-123-4567'
)
print('Redacted text:', pii_result['redacted_text'])
except Exception as error:
print('Error:', error)
example()
Using Individual Services
You can also use each service independently:
from tano_shield.firewall import FirewallClient
from tano_shield.pii import PIIClient
# Initialize just the Issue Detector client
firewall = FirewallClient(api_key="your-api-key")
# Check user input
result = firewall.check_input(
user_input='User message here',
system_prompt='You are a helpful assistant'
)
API Reference
TanoShield
The main client that provides access to all services.
tano_shield = TanoShield(
api_key="your-api-key",
base_url="https://api.example.com", # Optional
timeout=30, # Optional (default: 30)
version="v1" # Optional (default: 'v1')
)
Properties
firewall: FirewallClient instancepii: PIIClient instanceCREDIT_CONSTANTS: Credit cost constants
Methods
set_api_key(api_key): Update the API key for all services
FirewallClient (Issue Detector)
Client for the AI Issue Detector service.
Methods
check_input(**params): Check user input for security issuesparams['system_prompt']: The system prompt (optional)params['user_input']: The user input to check (required)params['response']: The AI response to check (optional)params['event_id']: A unique identifier for the event (optional)params['security_checks']: List of security checks to perform (optional)
get_settings(): Get Issue Detector settingsupdate_settings(settings): Update Issue Detector settingsget_history(**options): Get Issue Detector call historyget_analytics(**options): Get Issue Detector analytics
PIIClient
Client for the PII Redaction service.
Methods
redact_text(text, entity_types=None, mask_mode=False): Redact PII from textdetect_pii(text, entity_types=None): Detect PII in text without redactingget_supported_entity_types(): Get supported PII entity types
Credit System
Tano Shield uses a credit system for API usage. Each API call consumes credits based on the service used.
from tano_shield import CREDIT_CONSTANTS
print(CREDIT_CONSTANTS.FREE_CREDITS_PER_MONTH) # 1000
print(CREDIT_CONSTANTS.FIREWALL_CHECK_COST) # 1
print(CREDIT_CONSTANTS.PII_REDACTION_COST) # 1
Error Handling
The library provides custom error classes for different types of errors:
from tano_shield.core.errors import (
TanoShieldError,
AuthenticationError,
ApiRequestError
)
try:
tano_shield.firewall.check_input(user_input='test')
except AuthenticationError as error:
print('Authentication failed:', error)
except ApiRequestError as error:
print('API request failed:', error, error.status)
except TanoShieldError as error:
print('Tano Shield error:', error, error.code)
except Exception as error:
print('Unknown error:', error)
Example API Call
Here's an example of how to use the Issue Detector with requests:
import requests
import json
url = "https://api.tanolabs.com/api/v1/firewall-check"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
data = {
"prompt": "Tell me about AI security",
"system_prompt": "You are a helpful AI assistant",
"user_input": "Tell me about AI security",
"response": "I can provide information about AI security...",
"event_id": "conversation-12345",
"securityChecks": ["sycophancy", "faithfulness", "harmfulness", "implausible_output", "information_disclosure", "jailbreak"]
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
Building and Publishing
Local Development
To build and install the package locally:
# Navigate to the package directory
cd tano-shield-py
# Run the build and install script
./build_and_install.sh
Publishing to PyPI
To publish the package to PyPI:
- Update the version number in
setup.pyandpyproject.toml - Run the publish script:
./publish_to_pypi.sh
- Follow the prompts to publish to TestPyPI or PyPI
For detailed instructions, see PUBLISHING.md.
License
MIT
Metadata
Release files for tano-shield 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tano_shield-0.1.0.tar.gz | 12.9 kB | Without provenance | Details for tano_shield-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tano_shield-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tano_shield-0.1.0-py3-none-any.whl |
Total release size: 24.3 kB
Release files / tano_shield-0.1.0.tar.gz
| Download URL | tano_shield-0.1.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9c28151dc85440592d15397adc0bd25d073980519b9c88905ce9f4c282ed9a8
|
|
BLAKE2b-256 checksum How to use checksums |
19bbd090e48d8079520c9e89edc9009d11e8d0896b3e6ca190ab20b055c3474d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / tano_shield-0.1.0-py3-none-any.whl
| Download URL | tano_shield-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a7961229008c03abb3d3148d982588657714037ef25cdc9c6b4e2e14e3ac398c
|
|
BLAKE2b-256 checksum How to use checksums |
a990104a7715d8bdd9501916a3660ae165645d5ab4141b5a396d58382a49e6dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Security for tano-shield 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.