Interface GuardrailExecutor<C extends GuardrailsConfig, P extends GuardrailRequest<P>, R extends GuardrailResult<R>, G extends Guardrail<P,R>, E extends GuardrailExecutedEvent<P,R,G>>

Type Parameters:
C - The type of GuardrailsConfig to use for configuration
P - The type of GuardrailRequest to validate
R - The type of GuardrailResult to return
G - The type of Guardrails being executed
E - The type of GuardrailExecutedEvent to be fired
All Known Implementing Classes:
AbstractGuardrailExecutor, InputGuardrailExecutor, OutputGuardrailExecutor

public sealed interface GuardrailExecutor<C extends GuardrailsConfig, P extends GuardrailRequest<P>, R extends GuardrailResult<R>, G extends Guardrail<P,R>, E extends GuardrailExecutedEvent<P,R,G>> permits AbstractGuardrailExecutor<C,P,R,G,E,F>
Represents a mechanism to execute a set of guardrails on given parameters. This interface defines the contract for validating interactions (input or output) using multiple guardrails.
  • Method Details

    • config

      C config()
      The GuardrailsConfig to use for configuration of the guardrail execution
      Returns:
      The GuardrailsConfig to use for configuration of the guardrail execution
    • guardrails

      List<G> guardrails()
      Retrieves the guardrails associated with the implementation.
      Returns:
      The guardrails which can be used for validating inputs or outputs against predefined rules.
    • execute

      R execute(P request)
      Executes the provided guardrails on the given parameters.
      Parameters:
      request - The GuardrailRequest to validate
      Returns:
      The GuardrailResult of the validation
    • executeAsync

      CompletableFuture<R> executeAsync(P request)
      Non-blocking counterpart of execute(GuardrailRequest) for the asynchronous and reactive AI Service modes. Runs the guardrails — including, for output guardrails, any reprompt round-trips to the model — without blocking the calling thread.
      Parameters:
      request - The GuardrailRequest to validate
      Returns:
      A CompletableFuture that completes with the GuardrailResult of the validation
      Since:
      1.20.0