A tool use content block. Contains information about a tool that the
model is requesting be run., The model uses the result from the tool to
generate a response. For more information, see Call a tool with the
Converse
API
in the Amazon Bedrock User Guide.
Source code in src/aws_sdk_bedrock_runtime/models.py
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095 | @dataclass(kw_only=True)
class ToolUseBlock:
"""A tool use content block. Contains information about a tool that the
model is requesting be run., The model uses the result from the tool to
generate a response. For more information, see [Call a tool with the
Converse
API](https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use.html)
in the Amazon Bedrock User Guide.
"""
tool_use_id: str
"""The ID for the tool request."""
name: str
"""The name of the tool that the model wants to use."""
input: Document
"""The input to pass to the tool."""
type: str | None = None
"""The type for the tool request."""
def serialize(self, serializer: ShapeSerializer):
serializer.write_struct(_SCHEMA_TOOL_USE_BLOCK, self)
def serialize_members(self, serializer: ShapeSerializer):
serializer.write_string(
_SCHEMA_TOOL_USE_BLOCK.members["toolUseId"], self.tool_use_id
)
serializer.write_string(_SCHEMA_TOOL_USE_BLOCK.members["name"], self.name)
serializer.write_document(_SCHEMA_TOOL_USE_BLOCK.members["input"], self.input)
if self.type is not None:
serializer.write_string(_SCHEMA_TOOL_USE_BLOCK.members["type"], self.type)
@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["tool_use_id"] = de.read_string(
_SCHEMA_TOOL_USE_BLOCK.members["toolUseId"]
)
case 1:
kwargs["name"] = de.read_string(
_SCHEMA_TOOL_USE_BLOCK.members["name"]
)
case 2:
kwargs["input"] = de.read_document(
_SCHEMA_TOOL_USE_BLOCK.members["input"]
)
case 3:
kwargs["type"] = de.read_string(
_SCHEMA_TOOL_USE_BLOCK.members["type"]
)
case _:
logger.debug("Unexpected member schema: %s", schema)
deserializer.read_struct(_SCHEMA_TOOL_USE_BLOCK, consumer=_consumer)
return kwargs
|
The input to pass to the tool.
The name of the tool that the model wants to use.
The ID for the tool request.
The type for the tool request.