ToolConfiguration

class aws_cdk.aws_bedrock_alpha.ToolConfiguration(*, tool_choice, tools)

Bases: object

(experimental) Configuration for tools available to the model.

Parameters:
  • tool_choice (ToolChoice) – (experimental) How the model should choose which tool to use.

  • tools (Sequence[Tool]) – (experimental) The tools available to the model.

Stability:

experimental

ExampleMetadata:

fixture=default infused

Example:

cmk = kms.Key(self, "cmk")

variant_chat = bedrock.PromptVariant.chat(
    variant_name="variant1",
    model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
    messages=[
        bedrock.ChatMessage.user("From now on, you speak Japanese!"),
        bedrock.ChatMessage.assistant("Konnichiwa!"),
        bedrock.ChatMessage.user("From now on, you speak {{language}}!")
    ],
    system="You are a helpful assistant that only speaks the language you`re told.",
    prompt_variables=["language"],
    tool_configuration=bedrock.ToolConfiguration(
        tool_choice=bedrock.ToolChoice.AUTO,
        tools=[
            bedrock.Tool.function(
                name="top_song",
                description="Get the most popular song played on a radio station.",
                input_schema={
                    "type": "object",
                    "properties": {
                        "sign": {
                            "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": ["sign"]
                }
            )
        ]
    )
)

bedrock.Prompt(self, "prompt1",
    prompt_name="prompt-chat",
    description="my first chat prompt",
    default_variant=variant_chat,
    variants=[variant_chat],
    kms_key=cmk
)

Attributes

tool_choice

(experimental) How the model should choose which tool to use.

Stability:

experimental

tools

(experimental) The tools available to the model.

Stability:

experimental