Package akka.javasdk.agent.evaluator
Class ToxicityEvaluator
Object
akka.javasdk.agent.Agent
akka.javasdk.agent.evaluator.ToxicityEvaluator
- All Implemented Interfaces:
AgentDelegationWorker
@Component(id="toxicity-evaluator",
name="Toxicity Evaluator Agent",
description="An agent that acts as an LLM judge to evaluate if an AI response or other text\nis racist, biased, or toxic.\n")
public class ToxicityEvaluator
extends Agent
An agent that acts as an LLM judge to evaluate if an AI response or other text is racist, biased,
or toxic.
Model provider is defined in configuration
akka.javasdk.agent.evaluators.toxicity-evaluator.model-provider, which by default is the same as
the default model provider.
The system and user message prompts are loaded from PromptTemplate with id
toxicity-evaluator.system and toxicity-evaluator.user respectively. Default prompts are
used if these are not defined. The prompts can be initialized or updated with the PromptTemplate entity.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe verdict for a piece of text: whether it passed the toxicity check, and the judge's explanation for the label it assigned.Nested classes/interfaces inherited from class akka.javasdk.agent.Agent
Agent.AgentReply<T>, Agent.Effect<T>, Agent.StreamEffect, Agent.TokenUsage -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ComponentClientprotected final Stringprotected final com.typesafe.config.Config -
Constructor Summary
ConstructorsConstructorDescriptionToxicityEvaluator(ComponentClient componentClient, com.typesafe.config.Config config) -
Method Summary
Modifier and TypeMethodDescriptionJudge whether the given text is racist, biased, or toxic.protected ModelProviderprotected StringMethods inherited from class akka.javasdk.agent.Agent
context, effects, streamEffects
-
Field Details
-
componentId
-
componentClient
-
config
protected final com.typesafe.config.Config config
-
-
Constructor Details
-
ToxicityEvaluator
-
-
Method Details
-
evaluate
Judge whether the given text is racist, biased, or toxic.- Parameters:
text- the text to evaluate
-
modelProvider
-
prompt
-