The arguments for creating the document relevance evaluator.
Optionalchoices?: ClassificationChoicesMapOptionalinputMapping?: ObjectMapping<RecordType>The mapping of the input to evaluate to the shape that the evaluator expects
Optionalname?: stringOptionaloptimizationDirection?: OptimizationDirectionOptionalpromptTemplate?: PromptTemplateOptionaltelemetry?: TelemetryConfigAn evaluator function that takes a DocumentRelevanceExample and returns a classification result indicating whether the document is relevant to the input question.
const evaluator = createDocumentRelevanceEvaluator({ model: openai("gpt-4o-mini") });
const result = await evaluator.evaluate({
input: "What is the capital of France?",
documentText: "Paris is the capital and most populous city of France.",
});
console.log(result.label); // "relevant" or "unrelated"
Creates a document relevance evaluator function.
This function returns an evaluator that determines whether a given document text is relevant to a provided input question. The evaluator uses a classification model and a prompt template to make its determination.