Skip to content
Judgment Labs
Esc
navigateopen⌘Jpreview
On this page

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.

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

PropType
exampleId?string
Typestring
createdAt?string
Typestring
name?string | null
Typestring | 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

PropType
props?Record<string, unknown>
TypeRecord<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

PropType
dataExampleDict
TypeExampleDict

Returns

Example


get()

Get a property by key.

function get(key: string): unknown

Parameters

PropType
keystring
Typestring

Returns

unknown


has()

Check if a property key exists.

function has(key: string): boolean

Parameters

PropType
keystring
Typestring

Returns

boolean


toJSON()

Serialize to the API wire format.

function toJSON(): ExampleDict

Returns

ExampleDict

Was this page helpful?