For the complete documentation index, see llms.txt. This page is also available as Markdown.

Judges and Traces

Examples for judges and traces — create, list, update, delete; upload traces; run trace evaluations.

Examples for working with judges, traces, and trace evaluations on the Stratix platform using the LayerLens Python SDK.

Creating and Managing Judges

import time

from layerlens import Stratix

client = Stratix()

# Fetch a model to use as the judge's LLM
models = client.models.get(type="public", name="gpt-4o")
model = models[0]
print(f"Using model: {model.name} ({model.id})")

# --- Create a judge
judge = client.judges.create(
 name=f"Code Quality Judge {int(time.time())}",
 evaluation_goal="Evaluate the quality of code output including correctness, readability, and style",
 model_id=model.id,
)
print(f"Created judge {judge.id}: {judge.name}")

# --- Get a judge by ID
judge = client.judges.get(judge.id)
print(f"Judge: {judge.name}, version: {judge.version}")

# --- List all judges
response = client.judges.get_many()
print(f"Found {response.total_count} judges")
for j in response.judges:
 print(f" - {j.name} (v{j.version}, {j.run_count} runs)")

# --- Update a judge (creates a new version)
updated = client.judges.update(
 judge.id,
 name="Updated Code Quality Judge",
 evaluation_goal="Evaluate code output for correctness, readability, style, and security",
)
print(f"Updated judge {updated.id}")

# --- Delete a judge
deleted = client.judges.delete(judge.id)
print(f"Deleted judge {deleted.id}")

Uploading and Managing Traces

Running Trace Evaluations

Judge Optimizations

Optimization requires that the judge has at least 10 annotations (trace evaluation results). Run trace evaluations first to build up annotation data.

Async Judges and Traces

See Also

Error Handling

Last updated

Was this helpful?