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 URLapi_key(str, optional): API key for authenticationtimeout(float, default=10.0): Request timeout in secondsmax_retries(int, default=3): Maximum retry attempts
Methods:
evaluate(): Evaluate chatbot responsehealth_check(): Check service availabilityget_service_stats(): Get aggregate statistics
RAGDocument
Represents a retrieved document from RAG system.
Fields:
source(str): Document sourcecontent(str): Document textpage(int): Page numbersimilarity_score(float): Retrieval score (0-1)
EvaluationResult
Result from RAI evaluation.
Fields:
overall_score(float): Aggregate score (0-100)flagged(bool): Whether response requires reviewdimensions(DimensionScores): Individual dimension scoressession_id(str): Unique session IDtimestamp(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
- Documentation: https://endurance-rai.readthedocs.io
- Issues: https://github.com/yourcompany/endurance-sdk/issues
- Email: contact@endurance-rai.com
Project details
Release history Release notifications | RSS feed
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d673475dbf5ad46343188713f7f07c3248a9304c7760554b7ae311d25f553af2
|
|
| MD5 |
97c5c4b76df141433731fe57497320fb
|
|
| BLAKE2b-256 |
a1bd69b470b31dff330553902cfc7f0689ae54c8e47109a2f7b551455a13a3a8
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
233d5df0ac81f521719ac4c9221265b83285a7183acb8fe0991dd832f62fd48d
|
|
| MD5 |
6fedfa4133d1a8a93edcac525cd6b17c
|
|
| BLAKE2b-256 |
b33dd356aae093ba723fcb1567013d782846e0d3014104b08684966542c4cf46
|