Skip to main content

enterprise_ai.evaluation

Source: sdks/python/src/enterprise_ai/evaluation/__init__.py. Back to the Python SDK reference index.

note

This page is generated by tools/docs/gen_sdk_reference.py from the SDK sources and the OpenAPI text folders. Do not edit it by hand: change the source and regenerate.

Model CaseResult​

Result of one case of a local suite run: scores per metric, verdict, latency and error.

Fields:

NameTypeRequiredDescription
case_idstryesCase reference, 1 to 200 characters.
scoresdict[str, float]yesScore between 0 and 1 per metric name; empty when the target failed.
passedboolyesTrue when the target did not fail and every score reaches the min_score of the case (default 1).
latency_msfloatyesTime taken by the target, in milliseconds.
errorstr | NonenoException raised by the target as "<Type>: <message>", None when it answered.

Model SuiteResult​

Aggregated local run: per metric mean and gate verdict.

Fields:

NameTypeRequiredDescription
suitestryesName of the suite (suite by default).
caseslist[CaseResult]noCases of the suite: objects with input, optional system, expected values for the metrics and optionally a ready output.
thresholdfloatnoValue the score is compared with.

Attributes:

NameTypeRequiredDescription
metricsdict[str, float]yesMean score of each metric over all cases (a missing score counts 0).
pass_ratefloatyesShare of passed cases, between 0 and 1 (0 without cases).
passedboolyesGate verdict: true when there is at least one case and pass_rate reaches threshold.

SuiteResult.to_dict​

to_dict() -> dict[str, Any]

The result as a JSON ready dict.

This element takes no parameter.

Returns: dict[str, Any]. Dict {suite, pass_rate, passed, metrics, threshold, cases}.

Class EvaluationClient​

/v1/evaluations and /v1/redteam.

Resource

EvaluationClient.check_gate​

check_gate(target: dict[str, Any] | str, suite_ids: list[str] | None = None, **extra: Any) -> Any

Check the quality gate of a target. Checks that the latest finished run of every blocking suite of the target (for target.version when given, and limited to suite_ids when given) has passed. With run_missing: true, a suite without any run is run now; otherwise it counts as missing.

Route: /v1/evaluations/gates/check (POST).

NameTypeDefaultRequiredDescription
targetdict[str, Any] | stryesTarget whose blocking suites are checked; version restricts to the runs of that version.
suite_idslist[str] | NoneNonenoOnly these blocking suites. Null: every blocking suite of the target.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Check the quality gate of a target".

Raises: the typed errors of the transport (Errors).

EvaluationClient.compare​

compare(comparison: dict[str, Any]) -> Any

Compare a candidate with a baseline. Runs one suite twice, on the baseline and on the candidate (each {type, ref, version}, type model by default, agent or prompt), and stores both runs, the per metric deltas and the verdict. Deltas are oriented by the comparator of each metric (gte: higher is better, lte: lower is better).

Route: /v1/evaluations/comparisons (POST).

NameTypeDefaultRequiredDescription
comparisondict[str, Any]yesComparison to create: the suite and its baseline and candidate runs or targets.

Returns: Any. Decoded JSON answer of the operation "Compare a candidate with a baseline".

Raises: the typed errors of the transport (Errors).

EvaluationClient.create_suite​

create_suite(suite: dict[str, Any]) -> Any

Create an evaluation suite. Creates a suite. Needs tenant_admin, developer, security_officer or ai_governance_officer. Errors 400 invalid_request: target type not in model, agent, prompt, rag_pipeline, skill or tool, unknown engine or kind, comparator other than gte or lte, or, for the custom engine, a metric other than exact_match, contains, not_contains, json_valid, faithfulness, latency or refusal. A name already used answers 409 conflict. The dataset gets its size and a SHA-256 digest of the cases. Writes the audit event evaluation.suite.create.

Route: /v1/evaluations/suites (POST).

NameTypeDefaultRequiredDescription
suitedict[str, Any]yesSuite to create, as an Evaluation Contract.

Returns: Any. Decoded JSON answer of the operation "Create an evaluation suite".

Raises: the typed errors of the transport (Errors).

EvaluationClient.get_comparison​

get_comparison(comparison_id: str) -> Any

Get an A/B comparison. Returns one comparison. Needs tenant_admin, developer, security_officer, auditor, viewer or finops. Answers 404 comparison_not_found.

Route: /v1/evaluations/comparisons/{comparison_id} (GET).

NameTypeDefaultRequiredDescription
comparison_idstryesIdentifier (UUID) of the comparison.

Returns: Any. Decoded JSON answer of the operation "Get an A/B comparison".

Raises: the typed errors of the transport (Errors).

EvaluationClient.get_redteam_run​

get_redteam_run(run_id: str) -> Any

Get a red team run. Returns one red team run: target, engine, probes, status, summary (total, vulnerable, attack success rate, threshold, per category) and findings. Open to any member of the tenant. Answers 404 not_found.

Route: /v1/redteam/runs/{run_id} (GET).

NameTypeDefaultRequiredDescription
run_idstryesIdentifier (UUID) of the red team run.

Returns: Any. Decoded JSON answer of the operation "Get a red team run".

Raises: the typed errors of the transport (Errors).

EvaluationClient.get_run​

get_run(run_id: str) -> Any

Get an evaluation run. Returns one evaluation run with its results per metric and per case. Open to any member of the tenant. Answers 404 not_found.

Route: /v1/evaluations/runs/{run_id} (GET).

NameTypeDefaultRequiredDescription
run_idstryesIdentifier (UUID) of the evaluation run.

Returns: Any. Decoded JSON answer of the operation "Get an evaluation run".

Raises: the typed errors of the transport (Errors).

EvaluationClient.get_suite​

get_suite(suite_id: str) -> Any

Get an evaluation suite. Returns one suite with its full list of cases and run_on_promotion. Open to any member of the tenant. Answers 404 not_found.

Route: /v1/evaluations/suites/{suite_id} (GET).

NameTypeDefaultRequiredDescription
suite_idstryesIdentifier (UUID) of the suite.

Returns: Any. Decoded JSON answer of the operation "Get an evaluation suite".

Raises: the typed errors of the transport (Errors).

EvaluationClient.list_comparisons​

list_comparisons(suite_id: str | None = None) -> Any

List the A/B comparisons. Lists the comparisons of the tenant, newest first, at most 200, optionally for one suite. Each gives baseline, candidate, both run ids, per metric deltas, tolerance and verdict. Needs tenant_admin, developer, security_officer, auditor, viewer or finops.

Route: /v1/evaluations/comparisons (GET).

NameTypeDefaultRequiredDescription
suite_idstr | NoneNonenoOnly the comparisons of this suite (UUID).

Returns: Any. Decoded JSON answer of the operation "List the A/B comparisons".

Raises: the typed errors of the transport (Errors).

EvaluationClient.list_redteam_runs​

list_redteam_runs(**page: Any) -> Any

List the red team runs. Lists the red team runs of the tenant, newest identifier first, paginated, and probes: the builtin probes (id and category), the garak probe families and whether garak is installed. Open to any member of the tenant.

Route: /v1/redteam/runs (GET).

NameTypeDefaultRequiredDescription
**pageAnynoPagination options passed to the listing: limit (maximum number of items per page) and cursor (the next_cursor of the previous page). Iterating the returned page follows every cursor.

Returns: Any. Decoded JSON answer of the operation "List the red team runs".

Raises: the typed errors of the transport (Errors).

EvaluationClient.list_runs​

list_runs(suite_id: str | None = None, **page: Any) -> Any

List the evaluation runs. Lists the evaluation runs of the tenant, newest identifier first, paginated, optionally filtered by suite and status. Each item follows the Evaluation Contract (target, engine, dataset, metrics, results, status, cost) with run_id, suite_id, trigger, case_results and error. Open to any member of the tenant.

Route: /v1/evaluations/runs (GET).

NameTypeDefaultRequiredDescription
suite_idstr | NoneNonenoOnly the runs of this suite.
**pageAnynoPagination options passed to the listing: limit (maximum number of items per page) and cursor (the next_cursor of the previous page). Iterating the returned page follows every cursor.

Returns: Any. Decoded JSON answer of the operation "List the evaluation runs".

Raises: the typed errors of the transport (Errors).

EvaluationClient.list_suites​

list_suites(**page: Any) -> Any

List the evaluation suites. Lists the suites of the tenant ordered by name, paginated, as Evaluation Contract documents; cases gives the number of cases. Open to any member of the tenant.

Route: /v1/evaluations/suites (GET).

NameTypeDefaultRequiredDescription
**pageAnynoPagination options passed to the listing: limit (maximum number of items per page) and cursor (the next_cursor of the previous page). Iterating the returned page follows every cursor.

Returns: Any. Decoded JSON answer of the operation "List the evaluation suites".

Raises: the typed errors of the transport (Errors).

EvaluationClient.redteam​

redteam(target: dict[str, Any] | str, probes: list[str] | None = None, **extra: Any) -> Any

Run a red team campaign. Sends adversarial probes to the target and stores the findings. Needs tenant_admin, developer, security_officer or ai_governance_officer.

Route: /v1/redteam/runs (POST).

NameTypeDefaultRequiredDescription
targetdict[str, Any] | stryesTarget attacked: model, agent, prompt, rag_pipeline, skill or tool.
probeslist[str] | NoneNonenoProbes to send. Default: every builtin probe, or promptinject and dan for garak.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Run a red team campaign".

Raises: the typed errors of the transport (Errors).

EvaluationClient.run​

run(suite_id: str, target: dict[str, Any] | str, **extra: Any) -> Any

Run an evaluation suite. Runs a suite now and returns the finished run (201). Needs tenant_admin, developer, security_officer or ai_governance_officer or agent.

Route: /v1/evaluations/runs (POST).

NameTypeDefaultRequiredDescription
suite_idstryesSuite to run. Required unless trigger is promotion.
targetdict[str, Any] | stryesTarget to evaluate instead of the suite target, for example another version. Required for trigger: promotion without suite.
**extraAnynoExtra fields merged into the request body.

Returns: Any. Decoded JSON answer of the operation "Run an evaluation suite".

Raises: the typed errors of the transport (Errors).

EvaluationClient.run_local​

run_local(suite: dict[str, Any], target: Callable[[Any], Any]) -> SuiteResult

Run a suite locally with :func:run_suite.

NameTypeDefaultRequiredDescription
suitedict[str, Any]yesSuite {name, threshold, metrics, cases}, as for run_suite.
targetCallable[[Any], Any]yesCallable given the input of each case, whose return value is scored.

Returns: SuiteResult. A SuiteResult: Aggregated local run: per metric mean and gate verdict.

Functions​

exact_match​

exact_match(output: Any, case: dict[str, Any]) -> float

Metric: 1 when the output equals expected once trimmed, else 0.

NameTypeDefaultRequiredDescription
outputAnyyesOutput of the target; anything but text is compared as sorted JSON.
casedict[str, Any]yesCase of the suite, read for expected.

Returns: float. Score 1.0 or 0.0.

contains​

contains(output: Any, case: dict[str, Any]) -> float

Metric: share of the contains needles (or of expected) found in the output, case insensitive.

NameTypeDefaultRequiredDescription
outputAnyyesOutput of the target; anything but text is compared as sorted JSON.
casedict[str, Any]yesCase of the suite, read for contains (list) or expected.

Returns: float. Score between 0 and 1; 0 when the case gives no needle.

regex​

regex(output: Any, case: dict[str, Any]) -> float

Metric: 1 when the pattern of the case matches somewhere in the output, else 0.

NameTypeDefaultRequiredDescription
outputAnyyesOutput of the target; anything but text is searched as sorted JSON.
casedict[str, Any]yesCase of the suite, read for pattern (a Python regular expression).

Returns: float. Score 1.0 or 0.0.

json_valid​

json_valid(output: Any, case: dict[str, Any]) -> float

Metric: 1 when the output is valid JSON text (or not text at all), else 0.

NameTypeDefaultRequiredDescription
outputAnyyesOutput of the target.
casedict[str, Any]yesCase of the suite, unused by this metric.

Returns: float. Score 1.0 or 0.0.

json_schema​

json_schema(output: Any, case: dict[str, Any]) -> float

Metric: 1 when the output (parsed when it is text) is valid against the JSON Schema 2020-12 of the case.

NameTypeDefaultRequiredDescription
outputAnyyesOutput of the target; text that is not JSON scores 0.
casedict[str, Any]yesCase of the suite, read for schema.

Returns: float. Score 1.0 or 0.0.

max_length​

max_length(output: Any, case: dict[str, Any]) -> float

Metric: 1 when the output is at most max_length characters long (default 10000), else 0.

NameTypeDefaultRequiredDescription
outputAnyyesOutput of the target; anything but text is measured as sorted JSON.
casedict[str, Any]yesCase of the suite, read for max_length.

Returns: float. Score 1.0 or 0.0.

run_suite​

run_suite(suite: dict[str, Any], target: Callable[[Any], Any]) -> SuiteResult

Run suite = {name, threshold, metrics, cases: [{id, input, expected, ...}]} locally.

NameTypeDefaultRequiredDescription
suitedict[str, Any]yesSuite dict: name, threshold (default 1), metrics (default ["contains"]) and cases, each with id, input and the fields its metrics read.
targetCallable[[Any], Any]yesCallable given the input of each case; an exception fails that case only.

Returns: SuiteResult. A SuiteResult: Aggregated local run: per metric mean and gate verdict.