Interface OutputGuardrail


@Experimental("This feature is experimental and the API is subject to change") public interface OutputGuardrail
An output guardrail is a rule that is applied to the output of the model to ensure that the output is safe and meets the expectations.

Implementation should be exposed as a CDI bean, and the class name configured in OutputGuardrails.value() annotation.

Implementation should throw a OutputGuardrail.ValidationException when the validation fails. The exception can indicate whether the request should be retried and provide a reprompt message. In the case of reprompting, the reprompt message is added to the LLM context and the request is retried.

The maximum number of retries is configurable using quarkus.langchain4j.guardrails.max-retries, defaulting to 3.