Class SimilarityGuard

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

@Deprecated(since="3.7.0", forRemoval=true) public final class SimilarityGuard extends Object implements TextGuardrail
Deprecated, for removal: This API element is subject to removal in a future version.
Using SimilarityGuard for model-request or model-response is deprecated. SimilarityGuard will support only mcp-tool-request and mcp-tool-response. For model-request, use ModelCallSimilarityGuard. The SDK has no replacement for model-response.
The SimilarityGuard evaluates the text by making a similarity search in a dataset of "bad examples". If the similarity reaches the threshold, SimilarityGuard blocks the result.
  • Constructor Details

    • SimilarityGuard

      public SimilarityGuard(GuardrailContext context)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Reads bad-examples-resource-dir and threshold from the guardrail's config.
  • Method Details

    • threshold

      public double threshold()
      Deprecated, for removal: This API element is subject to removal in a future version.
      SimilarityGuard blocks text at or above this score.
    • badExamplesResourceDir

      public String badExamplesResourceDir()
      Deprecated, for removal: This API element is subject to removal in a future version.
      The classpath resource directory holding the "bad examples" dataset.
    • evaluate

      public Guardrail.Result evaluate(String text)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: TextGuardrail
      Evaluates if the text passes the guardrail or not.
      Specified by:
      evaluate in interface TextGuardrail