Annotation Interface OutputGuardrails
An annotation to apply guardrails to the output of the model.
Guardrails can only be used with AI Services and only on method that do not stream the response.
A guardrail is a rule that is applied to the output of the model to ensure that the output is safe and meets the
expectations.
When a validation fails, the result 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.
If the annotation is present on a class, the guardrails will be applied to all the methods of the class.
When several guardrails are applied, the order of the guardrails is important. Note that in case of retry or reprompt, all the guardrails will be re-applied to the new response.
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends OutputGuardrail>[]
The ordered list of guardrails to apply to the output of the model.
-
Element Details
-
value
Class<? extends OutputGuardrail>[] valueThe ordered list of guardrails to apply to the output of the model. The passed classes must be implementation ofOutputGuardrail
. The order of the classes is important as the guardrails are applied in the order they are listed. Note that guardrails cannot be present twice in the list.
-