Managing Metrics via Confident AI SDK
Overview
The Confident AI SDK exposes every Metric method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.
Methods
List Metrics
Lists all the custom metrics in your Confident AI project.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.metrics.list()For async mode, call a_list and await it as shown below:
result = await client.metrics.a_list(...)import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.metrics.list();Returns
This method returns an object of type MetricList.
Create Metric
Creates a custom metric in your Confident AI project and returns it. A GEVAL metric scores against criteria or evaluationSteps; a DAG metric needs algorithm set to DAG and a dag.
from confident_ai import ConfidentAI
from confident_ai.common import MetricEvaluationParam
client = ConfidentAI()
result = client.metrics.create(
name="Correctness",
multi_turn=False,
criteria="Determine if the actual output is correct based on the expected output.",
evaluation_params=[
MetricEvaluationParam.ACTUALOUTPUT,
MetricEvaluationParam.EXPECTEDOUTPUT
],
)For async mode, call a_create and await it as shown below:
result = await client.metrics.a_create(...)Parameters
| Parameter | Type | Description |
|---|---|---|
name | str | Required. The name of the metric, unique within your project. |
multi_turn | Optional[bool] | This is true when the metric evaluates conversations rather than single test cases. It decides which evaluationParams are valid and cannot be changed later. |
criteria | Optional[str] | The criteria the metric scores against. A GEVAL metric needs criteria or evaluationSteps. |
evaluation_steps | Optional[List[str]] | The steps the metric follows to score, as an alternative to criteria. |
evaluation_params | Optional[List[MetricEvaluationParam]] | The test case fields the metric evaluates. A single-turn metric needs at least one, and every field must match multiTurn. See MetricEvaluationParam. |
rubric | Optional[List[Rubric]] | Score ranges that anchor how the metric scores. See Rubric. |
algorithm | Optional[MetricAlgorithm] | See MetricAlgorithm. |
dag | Optional[MetricDag] | See MetricDag. |
questions | Optional[List[JevQuestion]] | The questions a JEVAL metric asks the decision model. Required when algorithm is JEVAL. See JevQuestion. |
prompt_config | Optional[PromptMetricConfig] | See PromptMetricConfig. |
import { ConfidentAI } from "confident-ai";
import { MetricEvaluationParam } from "confident-ai/common";
const client = new ConfidentAI();
const result = await client.metrics.create(
"Correctness",
{
multiTurn: false,
criteria: "Determine if the actual output is correct based on the expected output.",
evaluationParams: [
MetricEvaluationParam.ACTUALOUTPUT,
MetricEvaluationParam.EXPECTEDOUTPUT
]
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Required. The name of the metric, unique within your project. |
multiTurn | boolean | This is true when the metric evaluates conversations rather than single test cases. It decides which evaluationParams are valid and cannot be changed later. |
criteria | string | The criteria the metric scores against. A GEVAL metric needs criteria or evaluationSteps. |
evaluationSteps | string[] | The steps the metric follows to score, as an alternative to criteria. |
evaluationParams | MetricEvaluationParam[] | The test case fields the metric evaluates. A single-turn metric needs at least one, and every field must match multiTurn. See MetricEvaluationParam. |
rubric | Rubric[] | Score ranges that anchor how the metric scores. See Rubric. |
algorithm | MetricAlgorithm | See MetricAlgorithm. |
dag | MetricDag | See MetricDag. |
questions | JevQuestion[] | The questions a JEVAL metric asks the decision model. Required when algorithm is JEVAL. See JevQuestion. |
promptConfig | PromptMetricConfig | See PromptMetricConfig. |
Returns
This method returns an object of type Metric.
Get Metric
Retrieves a custom metric by id so it can be run locally. The metric must have criteria or evaluation steps and at least one evaluation parameter, or be a valid DAG.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.metrics.get(metric_id="<METRIC-ID>")For async mode, call a_get and await it as shown below:
result = await client.metrics.a_get(...)Parameters
| Parameter | Type | Description |
|---|---|---|
metric_id | str | Required. The unique id of the metric. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.metrics.get("<METRIC-ID>");Parameters
| Parameter | Type | Description |
|---|---|---|
metricId | string | Required. The unique id of the metric. |
Returns
This method returns an object of type Metric.
Update Metric
Updates a custom metric and returns it. Only the fields you send are changed; send null to clear criteria or evaluationSteps, as long as one of them remains. An update that changes the definition creates a new metric version; one that changes nothing creates none.
from confident_ai import ConfidentAI
from confident_ai.common import (
JevNoulQuestion,
MetricEvaluationParam,
PromptMetricConfig,
PromptMetricConfigMessage,
Rubric,
)
client = ConfidentAI()
result = client.metrics.update(
metric_id="<METRIC-ID>",
criteria="Determine if the actual output is correct based on the expected output.",
evaluation_steps=[
"Compare the actual output with the expected output.",
"Penalise any factual contradiction."
],
evaluation_params=[
MetricEvaluationParam.ACTUALOUTPUT,
MetricEvaluationParam.EXPECTEDOUTPUT
],
rubric=[
Rubric(
score_range=[8, 10],
expected_outcome="The answer is factually correct and complete."
)
],
questions=[
JevNoulQuestion(
type="noul",
question="<QUESTION>",
weight=0,
true_description="<TRUE-DESCRIPTION>",
false_description="<FALSE-DESCRIPTION>"
)
],
prompt_config=PromptMetricConfig(
messages=[
PromptMetricConfigMessage(
role="system",
content="You grade support answers."
),
PromptMetricConfigMessage(
role="user",
content="QUESTION: {{question}}\nANSWER: {{answer}}"
)
],
variables={
"question": {"field": "input", "path": ["messages", 0, "content"]},
"answer": {"field": "output", "path": ["messages", -1, "content"]}
}
),
)For async mode, call a_update and await it as shown below:
result = await client.metrics.a_update(...)Parameters
| Parameter | Type | Description |
|---|---|---|
metric_id | str | Required. The unique id of the metric. |
criteria | Optional[str] | The new criteria, or null to clear it. One of criteria or evaluationSteps must remain set. |
evaluation_steps | Optional[List[str]] | The new evaluation steps, or null to clear them. One of criteria or evaluationSteps must remain set. |
evaluation_params | Optional[List[MetricEvaluationParam]] | The test case fields the metric evaluates. Each must match the metric's multiTurn. See MetricEvaluationParam. |
rubric | Optional[List[Rubric]] | Score ranges that anchor how the metric scores. See Rubric. |
questions | Optional[List[JevQuestion]] | The new questions for a JEVAL metric. Only accepted on JEVAL metrics. See JevQuestion. |
prompt_config | Optional[PromptMetricConfig] | See PromptMetricConfig. |
import { ConfidentAI } from "confident-ai";
import { MetricEvaluationParam } from "confident-ai/common";
const client = new ConfidentAI();
const result = await client.metrics.update(
"<METRIC-ID>",
{
criteria: "Determine if the actual output is correct based on the expected output.",
evaluationSteps: [
"Compare the actual output with the expected output.",
"Penalise any factual contradiction."
],
evaluationParams: [
MetricEvaluationParam.ACTUALOUTPUT,
MetricEvaluationParam.EXPECTEDOUTPUT
],
rubric: [
{
scoreRange: [8, 10],
expectedOutcome: "The answer is factually correct and complete."
}
],
questions: [
{
type: "noul",
question: "<QUESTION>",
weight: 0,
trueDescription: "<TRUE-DESCRIPTION>",
falseDescription: "<FALSE-DESCRIPTION>"
}
],
promptConfig: {
messages: [
{
role: "system",
content: "You grade support answers."
},
{
role: "user",
content: "QUESTION: {{question}}\nANSWER: {{answer}}"
}
],
variables: {
question: { field: "input", path: ["messages", 0, "content"] },
answer: { field: "output", path: ["messages", -1, "content"] }
}
}
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
metricId | string | Required. The unique id of the metric. |
criteria | string | null | The new criteria, or null to clear it. One of criteria or evaluationSteps must remain set. |
evaluationSteps | string[] | null | The new evaluation steps, or null to clear them. One of criteria or evaluationSteps must remain set. |
evaluationParams | MetricEvaluationParam[] | The test case fields the metric evaluates. Each must match the metric's multiTurn. See MetricEvaluationParam. |
rubric | Rubric[] | Score ranges that anchor how the metric scores. See Rubric. |
questions | JevQuestion[] | The new questions for a JEVAL metric. Only accepted on JEVAL metrics. See JevQuestion. |
promptConfig | PromptMetricConfig | See PromptMetricConfig. |
Returns
This method returns an object of type Metric.
List Versions
Lists a custom metric's definition history, newest first, so the first entry is the definition new evaluations run. Versions are append-only: updating a metric with a changed definition adds one, and an update that changes nothing adds none.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.metrics.list_versions(
metric_id="<METRIC-ID>",
page=1,
page_size=25,
)For async mode, call a_list_versions and await it as shown below:
result = await client.metrics.a_list_versions(...)Parameters
| Parameter | Type | Description |
|---|---|---|
metric_id | str | Required. The unique id of the metric. |
page | Optional[int] | The page to return. Defaults to 1. |
page_size | Optional[int] | The number of versions per page, at most 100. Defaults to 25. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.metrics.listVersions("<METRIC-ID>", 1, 25);Parameters
| Parameter | Type | Description |
|---|---|---|
metricId | string | Required. The unique id of the metric. |
page | number | The page to return. Defaults to 1. |
pageSize | number | The number of versions per page, at most 100. Defaults to 25. |
Returns
This method returns an object of type MetricVersionList.
Types
JevQuestion
A bounded question a JEVAL metric asks the decision model: a noul (true/false) question, a score question over ordered levels (worst first), or a choice question over options with credits.
JevQuestion = Union[
JevNoulQuestion,
JevScoreQuestion,
JevChoiceQuestion,
]type JevQuestion =
| JevNoulQuestion
| JevScoreQuestion
| JevChoiceQuestion;A JevQuestion is one of the shapes below. Send the fields of one of them, never a mix of both.
A question the decision model answers true or false. trueDescription and falseDescription tell it what each answer means.
class JevNoulQuestion:
type: Literal["noul"]
question: str
weight: Optional[float] = None
true_description: Optional[str] = Field(default=None, alias="trueDescription")
false_description: Optional[str] = Field(default=None, alias="falseDescription")typeLiteral["noul"]Required
Marks this as a noul question.
questionstrRequired
The question the decision model answers.
weightOptional[float]
How heavily this question counts towards the metric's score, relative to the metric's other questions.
true_descriptionOptional[str]
What a true answer to this question means.
false_descriptionOptional[str]
What a false answer to this question means.
interface JevNoulQuestion {
type: "noul";
question: string;
weight?: number;
trueDescription?: string;
falseDescription?: string;
}type"noul"Required
Marks this as a noul question.
questionstringRequired
The question the decision model answers.
weightnumber
How heavily this question counts towards the metric's score, relative to the metric's other questions.
trueDescriptionstring
What a true answer to this question means.
falseDescriptionstring
What a false answer to this question means.
A question the decision model answers by picking one of levels, which are ordered worst first.
class JevScoreQuestion:
type: Literal["score"]
question: str
weight: Optional[float] = None
levels: List[str]typeLiteral["score"]Required
Marks this as a score question.
questionstrRequired
The question the decision model answers.
weightOptional[float]
How heavily this question counts towards the metric's score, relative to the metric's other questions.
levelsList[str]Required
Between 2 and 10 ordered levels, worst first.
interface JevScoreQuestion {
type: "score";
question: string;
weight?: number;
levels: string[];
}type"score"Required
Marks this as a score question.
questionstringRequired
The question the decision model answers.
weightnumber
How heavily this question counts towards the metric's score, relative to the metric's other questions.
levelsstring[]Required
Between 2 and 10 ordered levels, worst first.
A question the decision model answers by picking one of options, each carrying the credit that answer earns.
class JevChoiceQuestion:
type: Literal["choice"]
question: str
weight: Optional[float] = None
options: Dict[str, Optional[float]]typeLiteral["choice"]Required
Marks this as a choice question.
questionstrRequired
The question the decision model answers.
weightOptional[float]
How heavily this question counts towards the metric's score, relative to the metric's other questions.
optionsDict[str, Optional[float]]Required
Each option maps to a credit between 0 and 1, or null to mark the question not applicable when that option is likely.
interface JevChoiceQuestion {
type: "choice";
question: string;
weight?: number;
options: Record<string, number | null>;
}type"choice"Required
Marks this as a choice question.
questionstringRequired
The question the decision model answers.
weightnumber
How heavily this question counts towards the metric's score, relative to the metric's other questions.
optionsRecord<string, number | null>Required
Each option maps to a credit between 0 and 1, or null to mark the question not applicable when that option is likely.
Metric
A custom metric: how it scores, and which test case fields it needs.
class Metric:
id: str
name: str
algorithm: Optional[MetricAlgorithm]
criteria: Optional[str]
evaluation_steps: Optional[List[str]] = Field(alias="evaluationSteps")
rubric: Optional[List[Rubric]]
dag: Optional[MetricDag]
questions: Optional[List[JevQuestion]]
prompt_config: Optional[PromptMetricConfig] = Field(alias="promptConfig")
multi_turn: bool = Field(alias="multiTurn")
required_parameters: List[MetricEvaluationParam] = Field(alias="requiredParameters")idstrRequired
This is the unique id of the metric.
Example: "<METRIC-ID>"
namestrRequired
This is the name of the metric, unique within your project.
Example: "Correctness"
algorithmOptional[MetricAlgorithm]Required
See MetricAlgorithm.
criteriaOptional[str]Required
This is the criteria the metric scores against, or null when it uses evaluation steps.
Example: "Determine if the actual output is correct based on the expected output."
evaluation_stepsOptional[List[str]]Required
These are the steps the metric follows to score, or null when it uses criteria.
rubricOptional[List[Rubric]]Required
These are the score ranges that anchor how the metric scores, or null.
See Rubric.
dagOptional[MetricDag]Required
See MetricDag.
questionsOptional[List[JevQuestion]]Required
These are the questions a JEVAL metric asks the decision model, or null for other algorithms.
See JevQuestion.
prompt_configOptional[PromptMetricConfig]Required
This is the judge prompt of a PROMPT metric, or null for other algorithms.
See PromptMetricConfig.
multi_turnboolRequired
This is true when the metric evaluates conversations rather than single test cases.
Example: false
required_parametersList[MetricEvaluationParam]Required
The test case fields the metric needs to run.
Example: ["actualOutput","expectedOutput"]
interface Metric {
id: string;
name: string;
algorithm: MetricAlgorithm | null;
criteria: string | null;
evaluationSteps: string[] | null;
rubric: Rubric[] | null;
dag: MetricDag | null;
questions: JevQuestion[] | null;
promptConfig: PromptMetricConfig | null;
multiTurn: boolean;
requiredParameters: MetricEvaluationParam[];
}idstringRequired
This is the unique id of the metric.
Example: "<METRIC-ID>"
namestringRequired
This is the name of the metric, unique within your project.
Example: "Correctness"
algorithmMetricAlgorithm | nullRequired
See MetricAlgorithm.
criteriastring | nullRequired
This is the criteria the metric scores against, or null when it uses evaluation steps.
Example: "Determine if the actual output is correct based on the expected output."
evaluationStepsstring[] | nullRequired
These are the steps the metric follows to score, or null when it uses criteria.
rubricRubric[] | nullRequired
These are the score ranges that anchor how the metric scores, or null.
See Rubric.
dagMetricDag | nullRequired
See MetricDag.
questionsJevQuestion[] | nullRequired
These are the questions a JEVAL metric asks the decision model, or null for other algorithms.
See JevQuestion.
promptConfigPromptMetricConfig | nullRequired
This is the judge prompt of a PROMPT metric, or null for other algorithms.
See PromptMetricConfig.
multiTurnbooleanRequired
This is true when the metric evaluates conversations rather than single test cases.
Example: false
requiredParametersMetricEvaluationParam[]Required
The test case fields the metric needs to run.
Example: ["actualOutput","expectedOutput"]
MetricAlgorithm
The algorithm the metric is evaluated with. GEVAL scores against criteria or evaluation steps, DAG walks a decision graph, JEVAL asks a decision model bounded questions, PROMPT sends your own judge prompt to the evaluation model, CODE runs your own code, and DEFAULT is a built-in metric.
class MetricAlgorithm(Enum):
DEFAULT = "DEFAULT"
DAG = "DAG"
GEVAL = "GEVAL"
JEVAL = "JEVAL"
CODE = "CODE"
PROMPT = "PROMPT"enum MetricAlgorithm {
DEFAULT = "DEFAULT",
DAG = "DAG",
GEVAL = "GEVAL",
JEVAL = "JEVAL",
CODE = "CODE",
PROMPT = "PROMPT",
}DEFAULT · DAG · GEVAL · JEVAL · CODE · PROMPT
MetricCodeDefinition
The code a CODE metric runs to score a test case.
class MetricCodeDefinition:
language: Literal["PYTHON"]
code: strlanguageLiteral["PYTHON"]Required
This is the language the code is written in.
Example: "PYTHON"
codestrRequired
This is the source code the metric runs.
Example: "def measure(test_case): return 1.0"
interface MetricCodeDefinition {
language: "PYTHON";
code: string;
}language"PYTHON"Required
This is the language the code is written in.
Example: "PYTHON"
codestringRequired
This is the source code the metric runs.
Example: "def measure(test_case): return 1.0"
MetricDag
The decision graph of a DAG metric. It is validated on write, and metric references are resolved against the metrics in your project.
class MetricDag:
nodes: Dict[str, Any]nodesDict[str, Any]Required
The graph's nodes keyed by node id, as serialized by deepeval's DAG metric. Judgement nodes list their children by id; verdict nodes carry a verdict and a score, or point at another metric by metric_name.
Example: {"root":{"type":"BinaryJudgementNode","criteria":"Does the actual output answer the input?","evaluation_params":["input","actual_output"],"children":["pass","fail"]},"pass":{"type":"VerdictNode","verdict":true,"score":10},"fail":{"type":"VerdictNode","verdict":false,"score":0}}
interface MetricDag {
nodes: Record<string, unknown>;
}nodesRecord<string, unknown>Required
The graph's nodes keyed by node id, as serialized by deepeval's DAG metric. Judgement nodes list their children by id; verdict nodes carry a verdict and a score, or point at another metric by metric_name.
Example: {"root":{"type":"BinaryJudgementNode","criteria":"Does the actual output answer the input?","evaluation_params":["input","actual_output"],"children":["pass","fail"]},"pass":{"type":"VerdictNode","verdict":true,"score":10},"fail":{"type":"VerdictNode","verdict":false,"score":0}}
MetricEvaluationParam
A test case field a metric evaluates. Single-turn metrics take input, actualOutput, expectedOutput, context and expectedTools; multi-turn metrics take content, role, scenario, expectedOutcome, audio (GEVAL only) and turns; toolsCalled, retrievalContext, metadata and tags apply to both.
class MetricEvaluationParam(Enum):
INPUT = "input"
ACTUALOUTPUT = "actualOutput"
EXPECTEDOUTPUT = "expectedOutput"
CONTEXT = "context"
EXPECTEDTOOLS = "expectedTools"
CONTENT = "content"
ROLE = "role"
SCENARIO = "scenario"
EXPECTEDOUTCOME = "expectedOutcome"
AUDIO = "audio"
TURNS = "turns"
TOOLSCALLED = "toolsCalled"
RETRIEVALCONTEXT = "retrievalContext"
METADATA = "metadata"
TAGS = "tags"enum MetricEvaluationParam {
INPUT = "input",
ACTUALOUTPUT = "actualOutput",
EXPECTEDOUTPUT = "expectedOutput",
CONTEXT = "context",
EXPECTEDTOOLS = "expectedTools",
CONTENT = "content",
ROLE = "role",
SCENARIO = "scenario",
EXPECTEDOUTCOME = "expectedOutcome",
AUDIO = "audio",
TURNS = "turns",
TOOLSCALLED = "toolsCalled",
RETRIEVALCONTEXT = "retrievalContext",
METADATA = "metadata",
TAGS = "tags",
}INPUT · ACTUALOUTPUT · EXPECTEDOUTPUT · CONTEXT · EXPECTEDTOOLS · CONTENT · ROLE · SCENARIO · EXPECTEDOUTCOME · AUDIO · TURNS · TOOLSCALLED · RETRIEVALCONTEXT · METADATA · TAGS
MetricList
class MetricList:
metrics: List[Metric]metricsList[Metric]Required
This is the list of metrics.
See Metric.
interface MetricList {
metrics: Metric[];
}metricsMetric[]Required
This is the list of metrics.
See Metric.
MetricVersion
An immutable snapshot of a metric's definition. Saving a metric whose definition changed appends a new version instead of editing this one, and saving an unchanged definition appends nothing.
class MetricVersion:
id: str
version: str
sequence: int
created_at: str = Field(alias="createdAt")
algorithm: Optional[MetricAlgorithm]
criteria: Optional[str]
evaluation_steps: Optional[List[str]] = Field(alias="evaluationSteps")
rubric: Optional[List[Rubric]]
dag: Optional[MetricDag]
questions: Optional[List[JevQuestion]]
prompt_config: Optional[PromptMetricConfig] = Field(alias="promptConfig")
require_input: bool = Field(alias="requireInput")
require_actual_output: bool = Field(alias="requireActualOutput")
require_expected_output: bool = Field(alias="requireExpectedOutput")
require_context: bool = Field(alias="requireContext")
require_expected_tools: bool = Field(alias="requireExpectedTools")
require_content: bool = Field(alias="requireContent")
require_role: bool = Field(alias="requireRole")
require_scenario: bool = Field(alias="requireScenario")
require_expected_outcome: bool = Field(alias="requireExpectedOutcome")
require_audio: bool = Field(alias="requireAudio")
require_retrieval_context: bool = Field(alias="requireRetrievalContext")
require_tools_called: bool = Field(alias="requireToolsCalled")
require_metadata: bool = Field(alias="requireMetadata")
require_tags: bool = Field(alias="requireTags")
code_definition: Optional[MetricCodeDefinition] = Field(alias="codeDefinition")idstrRequired
This is the unique id of the version.
Example: "<METRIC-VERSION-ID>"
versionstrRequired
This is the human-readable label for sequence, written as three two-digit groups that roll over at 100, so sequence 2 is 00.00.02 and sequence 100 is 00.01.00.
Example: "00.00.02"
sequenceintRequired
This is the position of the version in the metric's history, counting from 1. The highest sequence is the definition new evaluations run.
Example: 2
created_atstrRequired
This is when the version was saved.
Example: "2025-01-18T16:45:00+00:00"
algorithmOptional[MetricAlgorithm]Required
See MetricAlgorithm.
criteriaOptional[str]Required
This is the criteria the version scores against, or null when it uses evaluation steps.
Example: "Determine if the actual output is correct based on the expected output."
evaluation_stepsOptional[List[str]]Required
These are the steps the version follows to score, or null when it uses criteria.
rubricOptional[List[Rubric]]Required
These are the score ranges that anchor how the version scores, or null.
See Rubric.
dagOptional[MetricDag]Required
See MetricDag.
questionsOptional[List[JevQuestion]]Required
These are the questions a JEVAL version asks the decision model, or null for other algorithms.
See JevQuestion.
prompt_configOptional[PromptMetricConfig]Required
This is the judge prompt of a PROMPT version, or null for other algorithms.
See PromptMetricConfig.
require_inputboolRequired
This is true when the metric needs the test case's input.
Example: false
require_actual_outputboolRequired
This is true when the metric needs the test case's actualOutput.
Example: false
require_expected_outputboolRequired
This is true when the metric needs the test case's expectedOutput.
Example: false
require_contextboolRequired
This is true when the metric needs the test case's context.
Example: false
require_expected_toolsboolRequired
This is true when the metric needs the test case's expectedTools.
Example: false
require_contentboolRequired
This is true when the metric needs the test case's content.
Example: false
require_roleboolRequired
This is true when the metric needs the test case's role.
Example: false
require_scenarioboolRequired
This is true when the metric needs the test case's scenario.
Example: false
require_expected_outcomeboolRequired
This is true when the metric needs the test case's expectedOutcome.
Example: false
require_audioboolRequired
This is true when the metric needs the test case's audio.
Example: false
require_retrieval_contextboolRequired
This is true when the metric needs the test case's retrievalContext.
Example: false
require_tools_calledboolRequired
This is true when the metric needs the test case's toolsCalled.
Example: false
require_metadataboolRequired
This is true when the metric needs the test case's metadata.
Example: false
require_tagsboolRequired
This is true when the metric needs the test case's tags.
Example: false
code_definitionOptional[MetricCodeDefinition]Required
This is the code a CODE version runs, or null for other algorithms.
See MetricCodeDefinition.
interface MetricVersion {
id: string;
version: string;
sequence: number;
createdAt: string;
algorithm: MetricAlgorithm | null;
criteria: string | null;
evaluationSteps: string[] | null;
rubric: Rubric[] | null;
dag: MetricDag | null;
questions: JevQuestion[] | null;
promptConfig: PromptMetricConfig | null;
requireInput: boolean;
requireActualOutput: boolean;
requireExpectedOutput: boolean;
requireContext: boolean;
requireExpectedTools: boolean;
requireContent: boolean;
requireRole: boolean;
requireScenario: boolean;
requireExpectedOutcome: boolean;
requireAudio: boolean;
requireRetrievalContext: boolean;
requireToolsCalled: boolean;
requireMetadata: boolean;
requireTags: boolean;
codeDefinition: MetricCodeDefinition | null;
}idstringRequired
This is the unique id of the version.
Example: "<METRIC-VERSION-ID>"
versionstringRequired
This is the human-readable label for sequence, written as three two-digit groups that roll over at 100, so sequence 2 is 00.00.02 and sequence 100 is 00.01.00.
Example: "00.00.02"
sequencenumberRequired
This is the position of the version in the metric's history, counting from 1. The highest sequence is the definition new evaluations run.
Example: 2
createdAtstringRequired
This is when the version was saved.
Example: "2025-01-18T16:45:00+00:00"
algorithmMetricAlgorithm | nullRequired
See MetricAlgorithm.
criteriastring | nullRequired
This is the criteria the version scores against, or null when it uses evaluation steps.
Example: "Determine if the actual output is correct based on the expected output."
evaluationStepsstring[] | nullRequired
These are the steps the version follows to score, or null when it uses criteria.
rubricRubric[] | nullRequired
These are the score ranges that anchor how the version scores, or null.
See Rubric.
dagMetricDag | nullRequired
See MetricDag.
questionsJevQuestion[] | nullRequired
These are the questions a JEVAL version asks the decision model, or null for other algorithms.
See JevQuestion.
promptConfigPromptMetricConfig | nullRequired
This is the judge prompt of a PROMPT version, or null for other algorithms.
See PromptMetricConfig.
requireInputbooleanRequired
This is true when the metric needs the test case's input.
Example: false
requireActualOutputbooleanRequired
This is true when the metric needs the test case's actualOutput.
Example: false
requireExpectedOutputbooleanRequired
This is true when the metric needs the test case's expectedOutput.
Example: false
requireContextbooleanRequired
This is true when the metric needs the test case's context.
Example: false
requireExpectedToolsbooleanRequired
This is true when the metric needs the test case's expectedTools.
Example: false
requireContentbooleanRequired
This is true when the metric needs the test case's content.
Example: false
requireRolebooleanRequired
This is true when the metric needs the test case's role.
Example: false
requireScenariobooleanRequired
This is true when the metric needs the test case's scenario.
Example: false
requireExpectedOutcomebooleanRequired
This is true when the metric needs the test case's expectedOutcome.
Example: false
requireAudiobooleanRequired
This is true when the metric needs the test case's audio.
Example: false
requireRetrievalContextbooleanRequired
This is true when the metric needs the test case's retrievalContext.
Example: false
requireToolsCalledbooleanRequired
This is true when the metric needs the test case's toolsCalled.
Example: false
requireMetadatabooleanRequired
This is true when the metric needs the test case's metadata.
Example: false
requireTagsbooleanRequired
This is true when the metric needs the test case's tags.
Example: false
codeDefinitionMetricCodeDefinition | nullRequired
This is the code a CODE version runs, or null for other algorithms.
See MetricCodeDefinition.
MetricVersionList
One page of a metric's definition history, with the total across all pages.
class MetricVersionList:
versions: List[MetricVersion]
total_metric_versions: int = Field(alias="totalMetricVersions")
page: int
page_size: int = Field(alias="pageSize")versionsList[MetricVersion]Required
The metric's definition history for the current page, newest version first, so the first entry of the first page is the current definition.
See MetricVersion.
total_metric_versionsintRequired
The number of versions this metric has, across every page.
Example: 2
pageintRequired
The page this response covers.
Example: 1
page_sizeintRequired
The number of versions per page.
Example: 25
interface MetricVersionList {
versions: MetricVersion[];
totalMetricVersions: number;
page: number;
pageSize: number;
}versionsMetricVersion[]Required
The metric's definition history for the current page, newest version first, so the first entry of the first page is the current definition.
See MetricVersion.
totalMetricVersionsnumberRequired
The number of versions this metric has, across every page.
Example: 2
pagenumberRequired
The page this response covers.
Example: 1
pageSizenumberRequired
The number of versions per page.
Example: 25
PromptMetricConfig
The judge prompt of a PROMPT metric, and how its variables are filled. The judge scores from 0 to 10 and the score is normalized to 0 to 1.
class PromptMetricConfig:
messages: List[PromptMetricConfigMessage]
variables: Dict[str, PromptMetricConfigVariables]messagesList[PromptMetricConfigMessage]Required
The judge prompt, as one or more messages.
variablesDict[str, PromptMetricConfigVariables]Required
Maps every {{name}} used in the messages to the data it is filled with.
interface PromptMetricConfig {
messages: PromptMetricConfigMessage[];
variables: Record<string, PromptMetricConfigVariables>;
}messagesPromptMetricConfigMessage[]Required
The judge prompt, as one or more messages.
variablesRecord<string, PromptMetricConfigVariables>Required
Maps every {{name}} used in the messages to the data it is filled with.
Rubric
A score range and the outcome it stands for. Ranges must not overlap.
class Rubric:
score_range: Tuple[int, int] = Field(alias="scoreRange")
expected_outcome: str = Field(alias="expectedOutcome")score_rangeTuple[int, int]Required
The inclusive start and end of the score range this outcome describes, each between 0 and 10, with the start no greater than the end.
Example: [8,10]
expected_outcomestrRequired
What a response scoring in this range looks like.
Example: "The answer is factually correct and complete."
interface Rubric {
scoreRange: [number, number];
expectedOutcome: string;
}scoreRange[number, number]Required
The inclusive start and end of the score range this outcome describes, each between 0 and 10, with the start no greater than the end.
Example: [8,10]
expectedOutcomestringRequired
What a response scoring in this range looks like.
Example: "The answer is factually correct and complete."
Last updated on