Skip to content

ToolResultBlockStart dataclass

The start of a tool result block. 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
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
@dataclass(kw_only=True)
class ToolResultBlockStart:
    """The start of a tool result block. 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 of the tool that was used to generate this tool result block."""

    type: str | None = None
    """The type for the tool that was used to generate this tool result block."""

    status: str | None = None
    """The status of the tool result block."""

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_TOOL_RESULT_BLOCK_START, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_string(
            _SCHEMA_TOOL_RESULT_BLOCK_START.members["toolUseId"], self.tool_use_id
        )
        if self.type is not None:
            serializer.write_string(
                _SCHEMA_TOOL_RESULT_BLOCK_START.members["type"], self.type
            )

        if self.status is not None:
            serializer.write_string(
                _SCHEMA_TOOL_RESULT_BLOCK_START.members["status"], self.status
            )

    @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_RESULT_BLOCK_START.members["toolUseId"]
                    )

                case 1:
                    kwargs["type"] = de.read_string(
                        _SCHEMA_TOOL_RESULT_BLOCK_START.members["type"]
                    )

                case 2:
                    kwargs["status"] = de.read_string(
                        _SCHEMA_TOOL_RESULT_BLOCK_START.members["status"]
                    )

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_TOOL_RESULT_BLOCK_START, consumer=_consumer)
        return kwargs

Attributes

status class-attribute instance-attribute

status: str | None = None

The status of the tool result block.

tool_use_id instance-attribute

tool_use_id: str

The ID of the tool that was used to generate this tool result block.

type class-attribute instance-attribute

type: str | None = None

The type for the tool that was used to generate this tool result block.