Skip to main content

Official Python SDK for Endurance RAI Engine

Project description

Endurance RAI SDK

Official Python SDK for Endurance RAI Engine - Responsible AI monitoring for government chatbots.

Installation

pip install endurance-rai

Or install from source:

git clone https://github.com/yourcompany/endurance-sdk.git
cd endurance-sdk
pip install -e .

Quick Start

import asyncio
from endurance import EnduranceClient, RAGDocument

async def main():
    # Initialize client
    client = EnduranceClient(
        base_url="https://lamaq-endurance-backend-4-hods.hf.space"
    )
    
    # Prepare RAG documents
    docs = [
        RAGDocument(
            source="FOI_Act_2000.pdf",
            content="Public authorities must respond within 20 working days...",
            page=1,
            similarity_score=0.95
        )
    ]
    
    # Evaluate chatbot response
    result = await client.evaluate(
        query="How long for FOI response?",
        response="Public authorities must respond within 20 working days.",
        service_id="uk_gov_chatbot",
        rag_documents=docs
    )
    
    # Check results
    print(f"Overall Score: {result.overall_score}/100")
    print(f"Flagged: {result.flagged}")
    print(f"Grounding: {result.dimensions.data_grounding}")

asyncio.run(main())

Features

  • Async/await support for non-blocking evaluations
  • Automatic retry logic with exponential backoff
  • Type hints for IDE autocomplete
  • Comprehensive error handling
  • 9 RAI dimensions evaluated

API Reference

EnduranceClient

Main client for interacting with Endurance RAI Engine.

Parameters:

  • base_url (str): Endurance backend URL
  • api_key (str, optional): API key for authentication
  • timeout (float, default=10.0): Request timeout in seconds
  • max_retries (int, default=3): Maximum retry attempts

Methods:

  • evaluate(): Evaluate chatbot response
  • health_check(): Check service availability
  • get_service_stats(): Get aggregate statistics

RAGDocument

Represents a retrieved document from RAG system.

Fields:

  • source (str): Document source
  • content (str): Document text
  • page (int): Page number
  • similarity_score (float): Retrieval score (0-1)

EvaluationResult

Result from RAI evaluation.

Fields:

  • overall_score (float): Aggregate score (0-100)
  • flagged (bool): Whether response requires review
  • dimensions (DimensionScores): Individual dimension scores
  • session_id (str): Unique session ID
  • timestamp (str): Evaluation timestamp

Error Handling

from endurance import EnduranceClient, EnduranceError, RateLimitError

client = EnduranceClient()

try:
    result = await client.evaluate(...)
except RateLimitError:
    print("Rate limit exceeded")
except EnduranceError as e:
    print(f"Error: {e}")

License

MIT License

Support

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

endurance_rai-1.0.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

endurance_rai-1.0.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file endurance_rai-1.0.0.tar.gz.

File metadata

  • Download URL: endurance_rai-1.0.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for endurance_rai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d673475dbf5ad46343188713f7f07c3248a9304c7760554b7ae311d25f553af2
MD5 97c5c4b76df141433731fe57497320fb
BLAKE2b-256 a1bd69b470b31dff330553902cfc7f0689ae54c8e47109a2f7b551455a13a3a8

See more details on using hashes here.

File details

Details for the file endurance_rai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: endurance_rai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for endurance_rai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 233d5df0ac81f521719ac4c9221265b83285a7183acb8fe0991dd832f62fd48d
MD5 6fedfa4133d1a8a93edcac525cd6b17c
BLAKE2b-256 b33dd356aae093ba723fcb1567013d782846e0d3014104b08684966542c4cf46

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