Annotation Interface InputGuardrails
AiServices
approach.
An input guardrail is a rule that is applied to the input of the model (essentially the user message) to ensure that the input is safe and meets the expectations of the model. It does not replace a moderation model, but it can be used to add additional checks (i.e. prompt injection, etc).
Unlike for output guardrails, the input guardrails do not support retry or reprompt. The failure is passed directly
to the caller, wrapped into a GuardrailException
.
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, as the guardrails are applied in the order they are listed.
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionClass<? extends InputGuardrail>[]
The ordered list ofInputGuardrail
s to apply to the input of the model.
-
Element Details
-
value
Class<? extends InputGuardrail>[] valueThe ordered list ofInputGuardrail
s to apply to the input of the model.The order of the classes is important as the guardrails are applied in the order they are listed. Guardrails can not be present twice in the list.
-