Files
wehub-resource-sync 5a558eb09e
TypeScript SDK Compatibility V1.x E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / TypeScript SDK Compatibility V1.x E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
TypeScript SDK E2E Tests / TypeScript SDK E2E Tests Node ${{matrix.node_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
Python SDK E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK E2E Tests / Python SDK E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK E2E Tests / build-opik (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Select Python version matrix (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / Python SDK Compatibility V1.x E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Python SDK Compatibility V1.x E2E Tests / build-opik (push) Has been cancelled
TypeScript SDK E2E Tests / Select Node version matrix (push) Has been cancelled
TypeScript SDK E2E Tests / build-opik (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer E2E Tests Python ${{matrix.python_version}} (push) Has been cancelled
Opik Optimizer - E2E Tests / Opik Optimizer Integration Smoke Tests (push) Has been cancelled
🐙 Code Quality / detect (push) Has been cancelled
🐙 Code Quality / lint (${{ matrix.leg.name }}) (push) Has been cancelled
🐙 Code Quality / summary (push) Has been cancelled
TypeScript SDK Library Integration Tests / Check Secrets (push) Has been cancelled
TypeScript SDK Library Integration Tests / opik-vercel (Vercel AI SDK / eve) (push) Has been cancelled
SDK Library Integration Tests Runner / Check Secrets (push) Has been cancelled
SDK Library Integration Tests Runner / Missed OpenAI API Key Warning (push) Has been cancelled
SDK Library Integration Tests Runner / Build (push) Has been cancelled
SDK Library Integration Tests Runner / openai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_tests (push) Has been cancelled
SDK Library Integration Tests Runner / langchain_legacy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / llama_index_tests (push) Has been cancelled
SDK Library Integration Tests Runner / anthropic_tests (push) Has been cancelled
SDK Library Integration Tests Runner / mistral_tests (push) Has been cancelled
SDK Library Integration Tests Runner / groq_tests (push) Has been cancelled
SDK Library Integration Tests Runner / aisuite_tests (push) Has been cancelled
SDK Library Integration Tests Runner / haystack_tests (push) Has been cancelled
SDK Library Integration Tests Runner / dspy_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / crewai_v1_tests (push) Has been cancelled
SDK Library Integration Tests Runner / genai_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_tests (push) Has been cancelled
SDK Library Integration Tests Runner / adk_legacy_1_3_0_tests (push) Has been cancelled
SDK Library Integration Tests Runner / evaluation_metrics_tests (push) Has been cancelled
SDK Library Integration Tests Runner / bedrock_tests (push) Has been cancelled
SDK Library Integration Tests Runner / litellm_tests (push) Has been cancelled
SDK Library Integration Tests Runner / harbor_tests (push) Has been cancelled
SDK Library Integration Tests Runner / Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / render-equality (push) Has been cancelled
Opik Optimizer - Unit Tests / Opik Optimizer Unit Tests Python ${{matrix.python_version}} (push) Has been cancelled
Python BE E2E Tests / Python BE E2E (push) Has been cancelled
Python Backend Tests / run-python-backend-tests (push) Has been cancelled
Python SDK Unit Tests / Python SDK Unit Tests ${{matrix.python_version}} (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
SDK E2E Libraries Integration Tests / Check Secrets (push) Has been cancelled
SDK E2E Libraries Integration Tests / Missed OpenAI API Key Warning (push) Has been cancelled
SDK E2E Libraries Integration Tests / build-opik (push) Has been cancelled
SDK E2E Libraries Integration Tests / E2E Lib Integration Python ${{matrix.python_version}} (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-gemini) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-langchain) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-openai) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-otel) (push) Has been cancelled
TypeScript SDK Integration Build & Publish / build-and-publish (opik-vercel) (push) Has been cancelled
TypeScript SDK Build & Publish / build-and-publish (push) Has been cancelled
TypeScript SDK Unit Tests / Test on Node ${{ matrix.node-version }} (push) Has been cancelled
Backend Tests / discover-tests (push) Has been cancelled
Backend Tests / ${{ matrix.name }} (push) Has been cancelled
Build and Publish SDK / build-and-publish (push) Has been cancelled
Build Opik Docker Images / set-version (push) Has been cancelled
Build Opik Docker Images / build-backend (push) Has been cancelled
Build Opik Docker Images / build-sandbox-executor-python (push) Has been cancelled
Build Opik Docker Images / build-python-backend (push) Has been cancelled
Build Opik Docker Images / build-frontend (push) Has been cancelled
Build Opik Docker Images / create-git-tag (push) Has been cancelled
ClickHouse Migration Cluster Check / validate-clickhouse-migrations (push) Has been cancelled
Docs - Publish / run (push) Has been cancelled
E2E Tests - Post Merge (v2) / 🧪 E2E v2 Tests (${{ github.event.inputs.tier || 't1' }}) (push) Has been cancelled
E2E Tests - Post Merge (v2) / 📢 Slack Notification (push) Has been cancelled
Frontend Unit Tests / Test on Node 20 (push) Has been cancelled
Guardrails E2E Tests / Select Python version matrix (push) Has been cancelled
Guardrails E2E Tests / Guardrails E2E Tests ${{matrix.python_version}} (push) Has been cancelled
Guardrails E2E Tests / 📢 Slack Notification (push) Has been cancelled
Guardrails Backend Unit Tests / Guardrails Backend Unit Tests (push) Has been cancelled
Guardrails Backend Unit Tests / 📢 Slack Notification (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v3.21.0) (push) Has been cancelled
Lint Opik Helm Chart / lint-helm-chart (Helm v4.2.0) (push) Has been cancelled
Lint Opik Helm Chart / unittest-helm-chart (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:25:44 +08:00

177 lines
6.3 KiB
Plaintext

---
headline: Getting Started with Evaluation | Opik Documentation
og:description: Get started evaluating your LLM application with Opik using Test
Suites or dataset-driven metrics
og:site_name: Opik Documentation
og:title: Getting Started with Evaluation — Opik
title: Getting started with Evaluation
---
Opik provides two approaches to evaluation. Choose the one that fits your use case:
- **Test Suites**: Define assertions in natural language and let an LLM judge test them. Best for pass/fail behavioral testing.
- **Datasets & Metrics**: Score outputs against a dataset using quantitative metrics. Best for measuring quality across many traces.
## Quick start
<Tabs>
<Tab title="Test Suites">
Test Suites let you define expected behaviors as natural-language assertions and run them
against your agent. An LLM judge checks each assertion automatically.
<CodeBlocks>
```python title="Python"
import opik
from openai import OpenAI
from opik.integrations.openai import track_openai
openai_client = track_openai(OpenAI())
opik_client = opik.Opik()
# Create a suite with assertions
suite = opik_client.get_or_create_test_suite(
name="my-agent-tests",
project_name="my-agent",
global_assertions=[
"The response directly addresses the user's question",
"The response is concise (3 sentences or fewer)",
],
global_execution_policy={"runs_per_item": 2, "pass_threshold": 2},
)
# Add test cases
suite.insert([
{"data": {"question": "How do I create a new project?", "context": "Go to Dashboard and click 'New Project'."}},
{"data": {"question": "What are the pricing tiers?", "context": "Free ($0/month), Pro ($29/month), Enterprise (custom)."}},
])
# Define the task
def task(item):
response = openai_client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": "Answer based ONLY on the provided context."},
{"role": "user", "content": f"Question: {item['question']}\n\nContext:\n{item['context']}"},
],
)
return {"input": item, "output": response.choices[0].message.content}
# Run the evaluation
result = opik.run_tests(test_suite=suite, task=task)
print(f"Pass rate: {result.pass_rate:.0%}")
```
```ts title="Typescript"
import { Opik, TestSuite, runTests } from "opik";
import OpenAI from "openai";
const client = new Opik();
const openai = new OpenAI();
// Create a suite with assertions
const suite = await TestSuite.getOrCreate(client, {
name: "my-agent-tests",
projectName: "my-agent",
globalAssertions: [
"The response directly addresses the user's question",
"The response is concise (3 sentences or fewer)",
],
globalExecutionPolicy: { runsPerItem: 2, passThreshold: 2 },
});
// Add test cases
await suite.insert([
{ data: { question: "How do I create a new project?", context: "Go to Dashboard and click 'New Project'." } },
{ data: { question: "What are the pricing tiers?", context: "Free ($0/month), Pro ($29/month), Enterprise (custom)." } },
]);
// Define the task
const task = async (item: Record<string, string>) => {
const response = await openai.chat.completions.create({
model: "gpt-4o-mini",
messages: [
{ role: "system", content: "Answer based ONLY on the provided context." },
{ role: "user", content: `Question: ${item.question}\n\nContext:\n${item.context}` },
],
});
return { input: item, output: response.choices[0].message.content };
};
// Run the evaluation
const result = await runTests({ testSuite: suite, task });
console.log(`Pass rate: ${((result.passRate ?? 0) * 100).toFixed(0)}%`);
```
</CodeBlocks>
Each run creates an experiment in the Opik dashboard for easy comparison.
<Frame>
<img src="/img/v2/evaluation/test-suite-run-results.png" alt="Test suite experiment results showing pass/fail per item with assertion details" />
</Frame>
See the [Building Test Suites](/evaluation/advanced/building-test-suites) guide for the full walkthrough.
</Tab>
<Tab title="Datasets & Metrics">
Dataset-based evaluation scores your agent's outputs using quantitative metrics like
hallucination detection, answer relevance, or custom scoring functions.
<CodeBlocks>
```python title="Python"
import opik
from opik.evaluation import evaluate
from opik.evaluation.metrics import Hallucination
opik.configure()
client = opik.Opik()
# Create a dataset
dataset = client.get_or_create_dataset(name="my-eval-dataset")
dataset.insert([
{"input": "What is the capital of France?", "expected_output": "Paris"},
{"input": "What is 2+2?", "expected_output": "4"},
])
# Define the task
def task(item):
# Your LLM call here
result = call_llm(item["input"])
return {"output": result}
# Run evaluation with metrics
evaluate(
dataset=dataset,
task=task,
scoring_metrics=[Hallucination()],
experiment_name="my-experiment-v1",
)
```
```ts title="Typescript"
import { Opik } from "opik";
const client = new Opik();
// Create a dataset
const dataset = await client.getOrCreateDataset({ name: "my-eval-dataset" });
await dataset.insert([
{ input: "What is the capital of France?", expectedOutput: "Paris" },
{ input: "What is 2+2?", expectedOutput: "4" },
]);
// Run evaluation with metrics
await client.evaluate({
dataset,
task: async (item) => {
const result = await callLlm(item.input);
return { output: result };
},
experimentName: "my-experiment-v1",
});
```
</CodeBlocks>
See the [Datasets & Experiments](/evaluation/advanced/evaluate_your_llm) guide for the full walkthrough
and the [Metrics](/evaluation/metrics/overview) section for all available metrics.
</Tab>
</Tabs>