Annotation Interface InputGuardrails


@Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface InputGuardrails
An annotation to apply guardrails to the input of the model.

Guardrails can only be used with AI Services.

An input guardrail is a rule that is applied to the input of the model (basically the user message) to ensure that the input is safe and meets the expectations of the model. It does not replace moderation model, but it can be used to add additional checks.

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 Elements
    Modifier and Type
    Required Element
    Description
    Class<? extends InputGuardrail>[]
    The ordered list of guardrails to apply to the input of the model.
  • Element Details

    • value

      Class<? extends InputGuardrail>[] value
      The ordered list of guardrails to apply to the input of the model. The passed classes must be implementation of InputGuardrail. 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.