API Reference
createEvaluator
Creates a basic evaluator for assessing AI-generated content based on custom criteria.
Parameters
client
: OpenAI instance.model
: OpenAI model to use (e.g., "gpt-4o").evaluationDescription
: Description guiding the evaluation criteria.resultsType
: Type of results to return ("score" or "binary").messages
: Additional messages to include in the OpenAI API call.
Example
createAccuracyEvaluator
Creates an evaluator that assesses string similarity using a hybrid approach of Levenshtein distance (factual similarity) and semantic embeddings (semantic similarity), with customizable weights.
Parameters
-
model
(optional): OpenAI.Embeddings.EmbeddingCreateParams["model"] - The OpenAI embedding model to use defaults to"text-embedding-3-small"
. -
weights
(optional): An object specifying the weights for factual and semantic similarities. Defaults to{
factual: 0.5, semantic: 0.5 }.
Example
createWeightedEvaluator
Combines multiple evaluators with specified weights for a comprehensive assessment.
Parameters
-
evaluators
: An object mapping evaluator names to evaluator functions. -
weights
: An object mapping evaluator names to their corresponding weights.
Example
Create Composite Weighted Evaluation
A weighted evaluator that incorporates various evaluation types: Example
createContextEvaluator
Creates an evaluator that assesses context-based criteria such as relevance, precision, recall, and entities recall.
Parameters
-
type
: "entities-recall" | "precision" | "recall" | "relevance" - The type of context evaluation to perform. -
model
(optional): OpenAI.Embeddings.EmbeddingCreateParams["model"] - The OpenAI embedding model to use. Defaults to"text-embedding-3-small"
.
Example