Class SimilarityGuard

Object
akka.javasdk.agent.SimilarityGuard
All Implemented Interfaces:
Guardrail, TextGuardrail

public final class SimilarityGuard extends Object implements 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.
  • Constructor Details

    • SimilarityGuard

      public SimilarityGuard(GuardrailContext context)
      Reads bad-examples-resource-dir and threshold from the guardrail's config.
  • Method Details

    • threshold

      public double threshold()
      The similarity score above which text is flagged as blocked.
    • badExamplesResourceDir

      public String badExamplesResourceDir()
      The classpath resource directory holding the "bad examples" dataset.
    • evaluate

      public Guardrail.Result evaluate(String text)
      Description copied from interface: TextGuardrail
      Evaluates if the text passes the guardrail or not.
      Specified by:
      evaluate in interface TextGuardrail