Judgment Labs Logo
Sdk referenceTypescript

Example

A single evaluation example with flexible key-value properties. Use `Example.create()` to construct an example with arbitrary fields such as `input`, `actualOutput`, `expectedOutput`, etc.

A single evaluation example with flexible key-value properties.

Use Example.create() to construct an example with arbitrary fields such as input, actualOutput, expectedOutput, etc.

const example = Example.create({
  input: "What is the capital of France?",
  actual_output: "Paris is the capital of France.",
  expected_output: "Paris",
});

example.get("input"); // "What is the capital of France?"

Attributes

exampleId

:

string

createdAt

:

string

name

:

string | null


Static Method

create()

Create an example with the given properties.

Any key-value pairs passed in props become accessible via .get(). Common keys: input, actual_output, expected_output, retrieval_context.

function create(props: Record<string, unknown> = {}): Example

Parameters

props

:

Record<string, unknown>

Default:

{}

Returns

Example


Static Method

from()

Reconstruct an Example from an API response dict.

Separates the fixed metadata fields (example_id, created_at, name) from user-defined properties.

function from(data: ExampleDict): Example

Parameters

data

required

:

ExampleDict

Returns

Example


get()

Get a property by key.

function get(key: string): unknown

Parameters

key

required

:

string

Returns

unknown


has()

Check if a property key exists.

function has(key: string): boolean

Parameters

key

required

:

string

Returns

boolean


toJSON()

Serialize to the API wire format.

function toJSON(): ExampleDict

Returns

ExampleDict

Last updated on