Welcome to Trustwise SDK’s documentation!

Trustwise SDK is a powerful tool for evaluating AI-generated content with Trustwise’s unified Metrics API.

Quickstart

  1. Install the SDK:

    pip install trustwise
    
  2. Set up and run your first evaluation:

    import os
    from trustwise.sdk import TrustwiseSDK
    from trustwise.sdk.config import TrustwiseConfig
    
    # Initialize the SDK
    config = TrustwiseConfig(api_key=os.environ["TW_API_KEY"])
    trustwise = TrustwiseSDK(config)
    
    # Evaluate faithfulness
    result = trustwise.metrics.faithfulness.evaluate(
        query="What is the capital of France?",
        response="The capital of France is Paris.",
        context=[{"node_id": "doc:idx:1", "node_score": 0.95, "node_text": "Paris is the capital of France."}]
    )
    print(f"Faithfulness score: {result.score}")
    

    Note

    All metrics are available in both synchronous and asynchronous forms. For async, use TrustwiseSDKAsync and await the evaluate() methods.

Documentation Overview

This documentation is organized to help you quickly find what you need:

  • Usage: Get started with basic setup, configuration, and comprehensive examples (Usage)

  • Metrics: Detailed documentation for all available evaluation metrics (see Metrics)

  • API Reference: Full technical documentation for all SDK features and metrics (API Reference)

  • API Versioning: Use explicit or default API versions for flexibility (API Versioning)

  • Changelog: Track documentation changes and feature additions (Changelog)

Indices and tables