Configuration information for the tools that you pass to a model. For
more information, see Tool use (function
calling)
in the Amazon Bedrock User Guide.
Source code in src/aws_sdk_bedrock_runtime/models.py
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453 | @dataclass(kw_only=True)
class ToolConfiguration:
"""Configuration information for the tools that you pass to a model. For
more information, see [Tool use (function
calling)](https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use.html)
in the Amazon Bedrock User Guide.
"""
tools: list[Tool]
"""An array of tools that you want to pass to a model."""
tool_choice: ToolChoice | None = None
"""If supported by model, forces the model to request a tool."""
def serialize(self, serializer: ShapeSerializer):
serializer.write_struct(_SCHEMA_TOOL_CONFIGURATION, self)
def serialize_members(self, serializer: ShapeSerializer):
_serialize_tools(
serializer, _SCHEMA_TOOL_CONFIGURATION.members["tools"], self.tools
)
if self.tool_choice is not None:
serializer.write_struct(
_SCHEMA_TOOL_CONFIGURATION.members["toolChoice"], self.tool_choice
)
@classmethod
def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
return cls(**cls.deserialize_kwargs(deserializer))
@classmethod
def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]:
kwargs: dict[str, Any] = {}
def _consumer(schema: Schema, de: ShapeDeserializer) -> None:
match schema.expect_member_index():
case 0:
kwargs["tools"] = _deserialize_tools(
de, _SCHEMA_TOOL_CONFIGURATION.members["tools"]
)
case 1:
kwargs["tool_choice"] = _ToolChoiceDeserializer().deserialize(de)
case _:
logger.debug("Unexpected member schema: %s", schema)
deserializer.read_struct(_SCHEMA_TOOL_CONFIGURATION, consumer=_consumer)
return kwargs
|
If supported by model, forces the model to request a tool.
An array of tools that you want to pass to a model.