Package akka.javasdk.agent
Class SimilarityGuard
Object
akka.javasdk.agent.SimilarityGuard
- All Implemented Interfaces:
Guardrail,TextGuardrail
The SimilarityGuard evaluates the text by making a similarity search in a dataset of "bad
examples". If the similarity exceeds a threshold, the result is flagged as blocked.
-
Nested Class Summary
Nested classes/interfaces inherited from interface akka.javasdk.agent.Guardrail
Guardrail.GuardrailException, Guardrail.Result -
Constructor Summary
ConstructorsConstructorDescriptionSimilarityGuard(GuardrailContext context) Readsbad-examples-resource-dirandthresholdfrom the guardrail's config. -
Method Summary
Modifier and TypeMethodDescriptionThe classpath resource directory holding the "bad examples" dataset.Evaluates if the text passes the guardrail or not.doubleThe similarity score above which text is flagged as blocked.
-
Constructor Details
-
SimilarityGuard
Readsbad-examples-resource-dirandthresholdfrom the guardrail's config.
-
-
Method Details
-
threshold
public double threshold()The similarity score above which text is flagged as blocked. -
badExamplesResourceDir
The classpath resource directory holding the "bad examples" dataset. -
evaluate
Description copied from interface:TextGuardrailEvaluates if the text passes the guardrail or not.- Specified by:
evaluatein interfaceTextGuardrail
-