Enum Class BedrockGuardContentPlacement

java.lang.Object
java.lang.Enum<BedrockGuardContentPlacement>
dev.langchain4j.model.bedrock.BedrockGuardContentPlacement
All Implemented Interfaces:
Serializable, Comparable<BedrockGuardContentPlacement>, Constable

public enum BedrockGuardContentPlacement extends Enum<BedrockGuardContentPlacement>
Defines which user messages a Bedrock guardrail evaluates as input.

By default, a guardrail configured via BedrockGuardrailConfiguration evaluates the text of all user and AI messages in the request. When a placement is set, the selected user messages are wrapped in Bedrock Converse guardContent blocks, and the guardrail evaluates only those blocks as input: other user messages and AI messages are not evaluated. The model response is still evaluated. This reduces cost and latency, but content outside the selected messages is not checked. For example, with LAST_USER_MESSAGE and chat memory, a user message that the guardrail blocked is sent to the model without evaluation on later turns.

Bedrock never evaluates tool results, tool definitions, tool calls or a system prompt, with or without a placement.

Only text and PNG/JPEG images can be wrapped. If a selected message contains other content (for example, a PDF or a GIF image), the placement is ignored for that request, the guardrail evaluates all user and AI messages as by default, and a warning is logged. The same default applies when the request contains no user message.

See Also:
  • Enum Constant Details

    • LAST_USER_MESSAGE

      public static final BedrockGuardContentPlacement LAST_USER_MESSAGE
      The guardrail evaluates only the last user message.
    • ALL_USER_MESSAGES

      public static final BedrockGuardContentPlacement ALL_USER_MESSAGES
      The guardrail evaluates only the user messages, all of them.
  • Method Details

    • values

      public static BedrockGuardContentPlacement[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static BedrockGuardContentPlacement valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null