Skip to main content

Python client for CAT Cafe - Continuous Alignment Testing platform for LLM observability

Project description

CAT Cafe SDK

Python SDK for CAT Cafe - Continuous Alignment Testing platform for LLM observability.

Installation

pip install cat-cafe-client

Compatibility: the client version tracks the CAT Cafe server API it targets. cat-cafe-client 0.10.0 targets the cat-cafe server 0.10.0 API.

Quick Start

from cat.cafe.client import CATCafeClient, DatasetImport, DatasetExample

# Initialize the client
client = CATCafeClient(base_url="http://localhost:8000")

# Create a dataset with examples in one call
dataset = DatasetImport(
    name="My Test Dataset",
    description="Sample dataset for testing",
    examples=[
        DatasetExample(
            input={"messages": [{"role": "user", "content": "What's the weather?"}]},
            expected={"messages": [{"role": "assistant", "content": "Weather info"}]},
            metadata={"tags": ["weather"]},
        )
    ],
)
result = client.import_dataset(dataset)
dataset_id = result["dataset"]["id"]

From here, run your AI system against the dataset and stream results to an experiment -- see "Manual Experiment Control" below for the full flow.

This SDK is the core HTTP client for CAT Cafe's dataset, experiment, and trace-scoring APIs. It intentionally does not include a task/evaluator runner -- for the higher-level workflow of defining a task function, evaluators, and running them against a dataset, use cat-experiments instead:

pip install "cat-experiments[cat-cafe]"

cat-experiments run experiment.py --dataset data.jsonl --storage cat-cafe

Core Classes

CATCafeClient

The main client for interacting with CAT Cafe:

client = CATCafeClient(base_url="http://localhost:8000")

Dataset Models

  • DatasetImport: For creating new datasets with examples
  • DatasetExample: Individual examples in a dataset
  • Dataset: Structured dataset object returned from API
  • Example: Individual example object returned from API

Experiment Models

  • Experiment: Experiment configuration
  • ExperimentResult: Results from running experiments

Key Methods

Dataset Operations

# Import a complete dataset
result = client.import_dataset(dataset_import)

# Add examples to an existing dataset (single or batch)
example_id = client.add_dataset_example(dataset_id, example)
client.add_dataset_examples(dataset_id, [example_a, example_b])

# Fetch dataset as structured object
dataset = client.fetch_dataset(dataset_id)

# Find dataset by name
dataset = client.fetch_dataset_by_name("My Dataset")

# List all datasets
datasets = client.list_datasets()

Experiment Operations

# Start an experiment tied to a dataset
experiment_id = client.start_experiment(experiment_config)

# Stream runs as you produce them
client.create_run(experiment_id, {...})
client.append_evaluation(experiment_id, run_id, {...})

# Mark it done
client.complete_experiment(experiment_id)

# Compare two experiments on the same dataset
comparison = client.compare_experiments(experiment_a_id, experiment_b_id)

Manual Experiment Control

from cat.cafe.client import CATCafeClient, Experiment

client = CATCafeClient(base_url="http://localhost:8000")

# Create experiment configuration
experiment_config = Experiment(
    name="Manual Experiment",
    description="Step-by-step experiment",
    dataset_id=dataset_id,
    tags=["manual", "testing"],
)

# Start experiment
experiment_id = client.start_experiment(experiment_config)

# Run your tests and stream results
dataset = client.fetch_dataset(dataset_id)

for example in dataset.examples:
    output = call_my_ai_system(example.input)  # however you invoke your system under test

    client.create_run(
        experiment_id,
        {
            "run_id": f"run-{example.id}",
            "example_id": example.id,
            "input_data": {"input": example.input},
            "output": dict(example.expected) if isinstance(example.expected, dict) else example.expected,
            "actual_output": output,
        },
    )
    client.append_evaluation(
        experiment_id,
        f"run-{example.id}",
        {"evaluator_name": "manual_score", "score": 0.8},
    )

# Complete experiment
client.complete_experiment(experiment_id, {"total_examples": len(dataset.examples)})

Requirements

  • Python 3.10+
  • httpx
  • CAT Cafe server running (default: http://localhost:8000)

License

Apache License 2.0 — see the LICENSE file in the cat-cafe repository 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

cat_cafe_client-0.10.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

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

cat_cafe_client-0.10.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file cat_cafe_client-0.10.0.tar.gz.

File metadata

  • Download URL: cat_cafe_client-0.10.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for cat_cafe_client-0.10.0.tar.gz
Algorithm Hash digest
SHA256 d1b81df3a823e32b63acf67c6c5998930a6c49156b62dc6823ae822609bac9fa
MD5 73715624d1b9b89cc7b74aaa7c23dd52
BLAKE2b-256 8f8600106460f5a85e9bb500e32e7163ae7d0238862cda4f367d384ad4cca342

See more details on using hashes here.

Provenance

The following attestation bundles were made for cat_cafe_client-0.10.0.tar.gz:

Publisher: publish-python-client.yml on thisisartium/cat-cafe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cat_cafe_client-0.10.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cat_cafe_client-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b5769397ae966aabc281917b8648bf4138d3b7d038e70282df92ddd9f5661d68
MD5 0eb825c42459ab26a3bcceee267e76e8
BLAKE2b-256 397868650ea8894a6cdaa8692a11efde88f74ddcbfca47ad14acf96f41fd007f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cat_cafe_client-0.10.0-py3-none-any.whl:

Publisher: publish-python-client.yml on thisisartium/cat-cafe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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