BindingContext: { inputMapping: ObjectMapping<RecordType> }

Context for binding an evaluator with input mapping configuration.

This type defines the structure for binding an evaluator to a specific data shape by mapping the evaluator's expected input fields to the actual data structure.

Type Parameters

  • RecordType extends Record<string, unknown>

    The type of the data record that will be evaluated

Type declaration

  • inputMapping: ObjectMapping<RecordType>

    Mapping of evaluator input fields to data source fields.

    The keys represent the field names expected by the evaluator (e.g., "input", "output", "reference"), and the values specify how to extract those fields from your data structure.

    Supports:

    • Simple property names: "fieldName"
    • Dot notation: "user.profile.name"
    • Array access: "items[0].id"
    • JSONPath expressions: "$.items[*].id"
    • Function extractors: (data) => data.customField.toUpperCase()
// Map evaluator fields to your data structure
const context: BindingContext<MyDataType> = {
inputMapping: {
input: "userQuery", // Maps "input" to "userQuery" field
reference: "context", // Maps "reference" to "context" field
output: "modelResponse", // Maps "output" to "modelResponse" field
},
};
// Using nested property access
const context: BindingContext<ApiResponse> = {
inputMapping: {
input: "request.body.query",
reference: "request.body.context",
output: "response.data.text",
},
};
// Using function-based mapping for transformations
const context: BindingContext<RawData> = {
inputMapping: {
input: "question",
reference: (data) => data.context.join("\n"), // Transform array to string
output: "answer",
},
};