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
Type
stringcreatedAt?string
Type
stringname?string | null
Type
string | nullStatic 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>
Type
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
PropType
dataExampleDict
Type
ExampleDictReturns
Example
get()
Get a property by key.
function get(key: string): unknown
Parameters
PropType
keystring
Type
stringReturns
unknown
has()
Check if a property key exists.
function has(key: string): boolean
Parameters
PropType
keystring
Type
stringReturns
boolean
toJSON()
Serialize to the API wire format.
function toJSON(): ExampleDict
Returns
ExampleDict