Interface OutputGuardrail

All Known Implementing Classes:
ContentPolicyGuardrail, 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 OutputGuardrail
Validates or transforms LLM output before it reaches the consumer.

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

Example — reject empty responses:


 OutputGuardrail nonEmpty = (output, ctx) ->
     CompletableFuture.completedFuture(
         output.isBlank()
             ? new GuardrailResult.Blocked("LLM returned empty response")
             : new GuardrailResult.Passed());
 
Since:
0.13.0
See Also:
  • Method Details