java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.bedrock.alpha.ToolChoice
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.112.0 (build de1bc80)", date="2025-08-06T02:30:07.621Z") @Stability(Experimental) public class ToolChoice extends software.amazon.jsii.JsiiObject
(experimental) Defines how the model should choose which tool to use.

Example:

 Key cmk = Key.Builder.create(this, "cmk").build();
 IPromptVariant variantChat = PromptVariant.chat(ChatPromptVariantProps.builder()
         .variantName("variant1")
         .model(BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0)
         .messages(List.of(ChatMessage.user("From now on, you speak Japanese!"), ChatMessage.assistant("Konnichiwa!"), ChatMessage.user("From now on, you speak {{language}}!")))
         .system("You are a helpful assistant that only speaks the language you`re told.")
         .promptVariables(List.of("language"))
         .toolConfiguration(ToolConfiguration.builder()
                 .toolChoice(ToolChoice.AUTO)
                 .tools(List.of(Tool.function(FunctionToolProps.builder()
                         .name("top_song")
                         .description("Get the most popular song played on a radio station.")
                         .inputSchema(Map.of(
                                 "type", "object",
                                 "properties", Map.of(
                                         "sign", Map.of(
                                                 "type", "string",
                                                 "description", "The call sign for the radio station for which you want the most popular song. Example calls signs are WZPZ and WKR.")),
                                 "required", List.of("sign")))
                         .build())))
                 .build())
         .build());
 Prompt.Builder.create(this, "prompt1")
         .promptName("prompt-chat")
         .description("my first chat prompt")
         .defaultVariant(variantChat)
         .variants(List.of(variantChat))
         .kmsKey(cmk)
         .build();
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final ToolChoice
    (experimental) The model must request at least one tool (no text is generated).
    static final ToolChoice
    (experimental) (Default).
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    ToolChoice(Object any, Object auto)
     
     
    ToolChoice(Object any, Object auto, String tool)
     
    protected
    ToolChoice(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    ToolChoice(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (experimental) Configuration for ANY tool choice.
    (experimental) Configuration for AUTO tool choice.
    (experimental) The specific tool name if using specific tool choice.
    static ToolChoice
    specificTool(String toolName)
    (experimental) The Model must request the specified tool.

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Field Details

    • ANY

      @Stability(Experimental) public static final ToolChoice ANY
      (experimental) The model must request at least one tool (no text is generated).
    • AUTO

      @Stability(Experimental) public static final ToolChoice AUTO
      (experimental) (Default).

      The Model automatically decides if a tool should be called or whether to generate text instead.

  • Constructor Details

    • ToolChoice

      protected ToolChoice(software.amazon.jsii.JsiiObjectRef objRef)
    • ToolChoice

      protected ToolChoice(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • ToolChoice

      @Stability(Experimental) public ToolChoice(@NotNull Object any, @NotNull Object auto, @Nullable String tool)
      Parameters:
      any - This parameter is required.
      auto - This parameter is required.
      tool -
    • ToolChoice

      @Stability(Experimental) public ToolChoice(@NotNull Object any, @NotNull Object auto)
      Parameters:
      any - This parameter is required.
      auto - This parameter is required.
  • Method Details

    • specificTool

      @Stability(Experimental) @NotNull public static ToolChoice specificTool(@NotNull String toolName)
      (experimental) The Model must request the specified tool.

      Only supported by some models like Anthropic Claude 3 models.

      Parameters:
      toolName -
      • The name of the specific tool to use.
      This parameter is required.
      Returns:
      A ToolChoice instance configured for the specific tool
    • getAny

      @Stability(Experimental) @Nullable public Object getAny()
      (experimental) Configuration for ANY tool choice.
    • getAuto

      @Stability(Experimental) @Nullable public Object getAuto()
      (experimental) Configuration for AUTO tool choice.
    • getTool

      @Stability(Experimental) @Nullable public String getTool()
      (experimental) The specific tool name if using specific tool choice.