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-client0.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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1b81df3a823e32b63acf67c6c5998930a6c49156b62dc6823ae822609bac9fa
|
|
| MD5 |
73715624d1b9b89cc7b74aaa7c23dd52
|
|
| BLAKE2b-256 |
8f8600106460f5a85e9bb500e32e7163ae7d0238862cda4f367d384ad4cca342
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cat_cafe_client-0.10.0.tar.gz -
Subject digest:
d1b81df3a823e32b63acf67c6c5998930a6c49156b62dc6823ae822609bac9fa - Sigstore transparency entry: 2220482857
- Sigstore integration time:
-
Permalink:
thisisartium/cat-cafe@f2e91cf481b36879caabefd7ba44a31afc40b129 -
Branch / Tag:
refs/tags/py-v0.10.0 - Owner: https://github.com/thisisartium
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-client.yml@f2e91cf481b36879caabefd7ba44a31afc40b129 -
Trigger Event:
push
-
Statement type:
File details
Details for the file cat_cafe_client-0.10.0-py3-none-any.whl.
File metadata
- Download URL: cat_cafe_client-0.10.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5769397ae966aabc281917b8648bf4138d3b7d038e70282df92ddd9f5661d68
|
|
| MD5 |
0eb825c42459ab26a3bcceee267e76e8
|
|
| BLAKE2b-256 |
397868650ea8894a6cdaa8692a11efde88f74ddcbfca47ad14acf96f41fd007f
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cat_cafe_client-0.10.0-py3-none-any.whl -
Subject digest:
b5769397ae966aabc281917b8648bf4138d3b7d038e70282df92ddd9f5661d68 - Sigstore transparency entry: 2220483249
- Sigstore integration time:
-
Permalink:
thisisartium/cat-cafe@f2e91cf481b36879caabefd7ba44a31afc40b129 -
Branch / Tag:
refs/tags/py-v0.10.0 - Owner: https://github.com/thisisartium
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python-client.yml@f2e91cf481b36879caabefd7ba44a31afc40b129 -
Trigger Event:
push
-
Statement type: