Skip to main content

Python library for evaluating LLM outputs across multiple ethical dimensions and performance metrics using Azure AI Evaluation services.

Project description

RAIT Connector

Python library for evaluating LLM outputs across multiple ethical dimensions and performance metrics using Azure AI Evaluation services.

Features

  • 22 Evaluation Metrics across 8 ethical dimensions
  • Parallel Execution for faster evaluations
  • Automatic API Integration with RAIT services
  • Type-Safe with Pydantic models
  • Flexible Configuration via environment variables or direct parameters
  • Batch Processing with custom callbacks
  • Comprehensive Documentation with examples

Installation

pip install rait-connector

Or with uv:

uv add rait-connector

Quick Start

from rait_connector import RAITClient

# Initialize client
client = RAITClient()

# Evaluate a single prompt
result = client.evaluate(
    prompt_id="123",
    prompt_url="https://example.com/123",
    timestamp="2025-12-11T10:00:00Z",
    model_name="gpt-4",
    model_version="1.0",
    query="What is AI?",
    response="AI is artificial intelligence...",
    environment="production",
    purpose="monitoring"
)

print(f"Evaluation complete: {result['prompt_id']}")

Configuration

Environment Variables

Set required environment variables:

# RAIT API
export RAIT_API_URL="https://api.raitracker.com"
export RAIT_CLIENT_ID="your-client-id"
export RAIT_CLIENT_SECRET="your-client-secret"
# Azure OpenAI
export AZURE_OPENAI_ENDPOINT="https://your.openai.azure.com"
export AZURE_OPENAI_API_KEY="your-api-key"
export AZURE_OPENAI_DEPLOYMENT="your-deployment"
# Azure AD
export AZURE_CLIENT_ID="your-azure-client-id"
export AZURE_TENANT_ID="your-azure-tenant-id"
export AZURE_CLIENT_SECRET="your-azure-client-secret"
# Azure Resources
export AZURE_SUBSCRIPTION_ID="your-subscription-id"
export AZURE_RESOURCE_GROUP="your-resource-group"
export AZURE_PROJECT_NAME="your-project-name"
export AZURE_ACCOUNT_NAME="your-account-name"

Direct Configuration

Or pass configuration directly:

client = RAITClient(
    rait_api_url="https://api.raitracker.com",
    rait_client_id="your-client-id",
    rait_client_secret="your-secret",
    azure_openai_endpoint="https://your.openai.azure.com",
    azure_openai_api_key="your-key",
    azure_openai_deployment="gpt-4",
    # ... other parameters
)

Evaluation Metrics

RAIT Connector supports 22 metrics across 8 ethical dimensions:

Dimension Metrics
Bias and Fairness Hate and Unfairness
Explainability and Transparency Ungrounded Attributes, Groundedness, Groundedness Pro
Monitoring and Compliance Content Safety
Legal and Regulatory Compliance Protected Materials
Security and Adversarial Robustness Code Vulnerability
Model Performance Coherence, Fluency, QA, Similarity, F1 Score, BLEU, GLEU, ROUGE, METEOR, Retrieval
Human-AI Interaction Relevance, Response Completeness
Social and Demographic Impact Sexual, Violence, Self-Harm

Batch Evaluation

Evaluate multiple prompts efficiently:

prompts = [
    {
        "prompt_id": "001",
        "prompt_url": "https://example.com/001",
        "timestamp": "2025-12-11T10:00:00Z",
        "model_name": "gpt-4",
        "model_version": "1.0",
        "query": "What is AI?",
        "response": "AI is...",
        "environment": "production",
        "purpose": "monitoring"
    },
    # ... more prompts
]

summary = client.evaluate_batch(prompts)
print(f"Completed: {summary['successful']}/{summary['total']}")

With Custom Callback

def on_complete(summary):
    print(f"Success: {summary['successful']}")
    print(f"Failed: {summary['failed']}")

client.evaluate_batch(prompts, on_complete=on_complete)

Parallel Execution

Control parallelism for faster evaluations:

result = client.evaluate(
    ...,
    parallel=True,
    max_workers=10  # Use 10 parallel workers
)

Documentation

Full documentation is available in the docs/ directory:

Requirements

  • Python 3.12+
  • Azure OpenAI access
  • RAIT API credentials

Development

Setup

Clone the repository:

git clone https://github.com/Responsible-Systems/rait-connector.git
cd rait-connector

Install dependencies:

uv sync --dev

Install pre-commit hooks:

uv tool install pre-commit
pre-commit install

Project Documentation

Serve docs locally:

uv run mkdocs serve

Build docs:

uv run mkdocs build

Contributing

Contributions are welcome! Please read our contributing guidelines.

Support

For issues and questions:

Changelog

See CHANGELOG.md for release history.

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

rait_connector-0.1.0.tar.gz (140.4 kB view details)

Uploaded Source

Built Distribution

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

rait_connector-0.1.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rait_connector-0.1.0.tar.gz
  • Upload date:
  • Size: 140.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for rait_connector-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c624a6ca70cfc26807eaaf8ed354cbe0b9c71782347ed5b39c14db1b8c443d3
MD5 34c8a086995009e1abd7945d226606af
BLAKE2b-256 2b1e516c87a384fe0803dcb4c5308498d0c35c87d7bfdd83b465f01d95525956

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rait_connector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22929393961d33c5ec4359a456cc191f0da95ea67bec9729689afdedf7291bdd
MD5 2b9c587ebd156eac90e62ddc1249624d
BLAKE2b-256 e728dd7332c65bec77c8ffebacd03cf4f631c572fb6e3dba8728d27abd2aa5e5

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