Class EvaluatorsPlugin
java.lang.Object
com.google.genkit.plugins.evaluators.EvaluatorsPlugin
- All Implemented Interfaces:
Plugin
Evaluators plugin for Genkit.
This plugin provides a set of pre-defined evaluators for assessing the quality of your LLM outputs. Evaluators include:
- FAITHFULNESS - Measures factual accuracy against provided context
- ANSWER_RELEVANCY - Assesses how well the answer pertains to the question
- ANSWER_ACCURACY - Compares output against a reference answer
- MALICIOUSNESS - Detects harmful, misleading, or deceptive content
- REGEX - Validates output against a regex pattern
- DEEP_EQUAL - Checks deep equality between output and reference
- JSONATA - Evaluates output using JSONata expressions
Example usage:
Genkit genkit = Genkit.builder()
.addPlugin(EvaluatorsPlugin.create(EvaluatorsPluginOptions.builder().judge("googleai/gemini-2.0-flash")
.metricTypes(List.of(GenkitMetric.FAITHFULNESS, GenkitMetric.ANSWER_RELEVANCY)).build()))
.build();
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an EvaluatorsPlugin with default options.EvaluatorsPlugin(EvaluatorsPluginOptions options) Creates an EvaluatorsPlugin with the specified options. -
Method Summary
Modifier and TypeMethodDescriptionstatic EvaluatorsPlugincreate()Creates an EvaluatorsPlugin with default options.static EvaluatorsPlugincreate(EvaluatorsPluginOptions options) Creates an EvaluatorsPlugin with the specified options.getName()Returns the unique identifier for the plugin.Gets the plugin options.init()Initializes the plugin.Initializes the plugin with access to the registry.
-
Constructor Details
-
EvaluatorsPlugin
public EvaluatorsPlugin()Creates an EvaluatorsPlugin with default options. -
EvaluatorsPlugin
Creates an EvaluatorsPlugin with the specified options.- Parameters:
options- the plugin options
-
-
Method Details
-
create
Creates an EvaluatorsPlugin with default options.- Returns:
- a new EvaluatorsPlugin
-
create
Creates an EvaluatorsPlugin with the specified options.- Parameters:
options- the plugin options- Returns:
- a new EvaluatorsPlugin
-
getName
Description copied from interface:PluginReturns the unique identifier for the plugin. This name is used for registration and lookup. -
init
Description copied from interface:PluginInitializes the plugin. This method is called once during Genkit initialization. The plugin should return a list of actions that it provides. -
init
Description copied from interface:PluginInitializes the plugin with access to the registry. This method is called once during Genkit initialization. The plugin should return a list of actions that it provides.Override this method instead of
Plugin.init()when your plugin needs to resolve dependencies from the registry (e.g., embedders, models). -
getOptions
Gets the plugin options.- Returns:
- the options
-