Interface InputGuardrail

All Known Implementing Classes:
ContentPolicyGuardrail, MaxTokensInputGuardrail, PiiRedactionGuardrail
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface InputGuardrail
Validates or transforms user input before it reaches the LLM.

This is a functional interface: implementations can be supplied as lambdas or method references when a one-liner is sufficient.

Example — simple length check:


 InputGuardrail lengthCheck = (input, ctx) ->
     CompletableFuture.completedFuture(
         input.length() > 4096
             ? new GuardrailResult.Blocked("Input exceeds maximum length")
             : new GuardrailResult.Passed());
 
Since:
0.13.0
See Also:
  • Method Details