Skip to main content

TavoAI SDK for AI risk controls evaluation

Project description

TavoAI SDK

A Python SDK for integrating with TavoAI's risk control as code (RCAC) guardrails.

PyPI version Python Versions License: MIT

1. Introduction

The TavoAI SDK provides a simple, intuitive interface for evaluating content against regulatory guardrails defined in the TavoAI RCAC repository. This SDK allows you to validate both input queries and output responses to ensure compliance with industry-specific regulations and best practices.

TavoAI's risk control as code (RCAC) guardrails help ensure AI systems comply with industry-specific regulations across financial services, healthcare, insurance, and more. The SDK supports both synchronous validation of content through a client API and automatic validation through function decorators.

Features

  • Easy Integration: Simple API to validate content against regulatory policies
  • Multiple Domains: Support for financial, healthcare, insurance and more
  • Input & Output Validation: Validate both user queries and AI responses
  • Multiple Use Modes: Support for both local OPA CLI evaluation and remote policy server
  • Decorator Support: Simple decorator API to automatically validate function inputs and outputs
  • Custom Configuration: Flexible metadata and configuration options

2. Get Started with Local Dev Environment

2.1 Install tavo-cli Tool to Spin Up a Local Server

To use the TavoAI SDK, you'll need a running policy server. The easiest way to get started is with the tavo-cli tool.

For installation instructions, please visit the official tavo-cli GitHub repository:

https://github.com/TavoAI/tavo-cli#tavo-cli

The repository provides platform-specific installation instructions for macOS and Linux.

2.2 Local Dev Server Usage

See instructions for the local dev server here:

https://github.com/TavoAI/tavo-cli#usage

3. Quick Start

3.1 Client API

from tavoai.sdk import TavoAIClient

# Initialize the client with the policy server URL
client = TavoAIClient(api_base_url="http://localhost:5000")

# Example metadata and configuration
metadata = {
    "jurisdiction": "US",
    "industry": "financial",
    "use_case": "investment_advice"
}

config = {
    "pii_detection_enabled": True,
    "misinformation_detection_enabled": True
}

# Evaluate an input query
input_result = client.evaluate_input(
    content="What stocks should I invest in for my retirement?",
    policy_name="financial_advice_input",
    metadata=metadata,
    config=config
)

# Check if the input is allowed
if input_result.allowed:
    print("Input content is allowed!")
else:
    print("Input content is not allowed!")
    for reason in input_result.rejection_reasons:
        print(f"{reason.get('category')}: {reason.get('reason')}")

# Evaluate an output response
output_result = client.evaluate_output(
    content="While I cannot provide specific investment advice...",
    policy_name="financial_advice_output",
    metadata=metadata,
    config=config
)

3.2 Decorator API

The decorator API provides a more convenient way to automatically validate function inputs and outputs:

from tavoai.sdk import TavoAIClient, TavoAIGuardrail

# Initialize client
client = TavoAIClient(api_base_url="http://localhost:5000")

# Create a guardrail decorator with shared configuration
guardrail = TavoAIGuardrail(
    client=client,
    metadata={"jurisdiction": "US", "industry": "financial"}
)

# Apply decorator with specific policy names
@guardrail("financial_advice_input", "financial_advice_output")
def get_financial_advice(query: str) -> str:
    # This function would typically call an LLM API
    return "Thank you for your question about financial planning..."

# The decorator will validate both the input and output
response = get_financial_advice("How should I invest for retirement?")

4. Examples

The SDK includes several example scripts demonstrating different usage patterns:

  • Basic Usage: Simple examples of using the client and decorator APIs
  • Client Example: Detailed examples of using the client API for input and output validation
  • Decorator Example: Detailed examples of using the decorator API for automatic validation

See the examples directory for full working examples.

Available Guardrails

The SDK provides predefined guardrail types for various domains:

Financial Services

  • financial_advice_input/output: Guardrails for financial advice content
  • financial_data_protection_input/output: Protection of financial data and PII
  • investment_recommendations_input/output: Investment-specific advice

Healthcare

  • medical_information_input/output: General medical information guardrails
  • patient_data_protection_input/output: Protection of patient data and PHI
  • mental_health_support_input/output: Mental health-related guidance

Insurance

  • insurance_claims_advice_input/output: Guidance on insurance claims
  • insurance_policy_guidance_input/output: Information about insurance policies

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

tavoai_sdk-0.1.0.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

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

tavoai_sdk-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tavoai_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for tavoai_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 258be9ae79646710400a30440eddd5059ebcbec276bdc6d5377348fec58f992e
MD5 1cd1fc1f3c27d341854e53907e4f6ad0
BLAKE2b-256 6ff8724934f847e4db8f712ddc07aed191749251ba254a985ebb954c62f5581a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tavoai_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for tavoai_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9ecdba8a97c0ac13a2695159bbf14ef90992ae4a20c6c6665237ec5068b067f
MD5 64360d666e6d8daae25c20d19a5ea3fa
BLAKE2b-256 73f7b39f9b436cd8903e75b2957141755f60d9c31fdd1462173c5951f961da42

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