Interface Guardrail<P extends GuardrailRequest, R extends GuardrailResult<R>>

Type Parameters:
P - The type of the GuardrailRequest
R - The type of the GuardrailResult
All Known Subinterfaces:
InputGuardrail, OutputGuardrail
All Known Implementing Classes:
JsonExtractorOutputGuardrail, JsonExtractorOutputGuardrail, MessageModeratorInputGuardrail

public interface Guardrail<P extends GuardrailRequest, R extends GuardrailResult<R>>
A guardrail is a rule that is applied when interacting with an LLM either to the input (the user message) or to the output of the model to ensure that they are safe and meet the expectations of the model.
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Returns the logical name of this guardrail.
    validate(P request)
    Validate the interaction between the model and the user in one of the two directions.
  • Method Details

    • name

      default String name()
      Returns the logical name of this guardrail. Wrappers/decorators can override this method to expose the wrapped guardrail's name.
      Returns:
      the logical guardrail name
    • validate

      R validate(P request)
      Validate the interaction between the model and the user in one of the two directions.
      Parameters:
      request - The parameters of the request or the response to be validated
      Returns:
      The result of the validation