Skip to content

tool

StructureRunTool

Bases: BaseTool

Tool for running a Structure.

Attributes:

Name Type Description
description str

A description of what the Structure does.

driver BaseStructureRunDriver

Driver to run the Structure.

Source code in griptape/tools/structure_run/tool.py
@define
class StructureRunTool(BaseTool):
    """Tool for running a Structure.

    Attributes:
        description: A description of what the Structure does.
        driver: Driver to run the Structure.
    """

    description: str = field(kw_only=True)
    driver: BaseStructureRunDriver = field(kw_only=True)

    @activity(
        config={
            "description": "Can be used to run a Griptape Structure with the following description: {{ _self.description }}",
            "schema": Schema(
                {
                    Literal("args", description="A list of string arguments to submit to the Structure Run"): Schema(
                        [str]
                    )
                },
            ),
        },
    )
    def run_structure(self, params: dict) -> BaseArtifact:
        args: list[str] = params["values"]["args"]

        return self.driver.run(*[TextArtifact(arg) for arg in args])

description: str = field(kw_only=True) class-attribute instance-attribute

driver: BaseStructureRunDriver = field(kw_only=True) class-attribute instance-attribute

run_structure(params)

Source code in griptape/tools/structure_run/tool.py
@activity(
    config={
        "description": "Can be used to run a Griptape Structure with the following description: {{ _self.description }}",
        "schema": Schema(
            {
                Literal("args", description="A list of string arguments to submit to the Structure Run"): Schema(
                    [str]
                )
            },
        ),
    },
)
def run_structure(self, params: dict) -> BaseArtifact:
    args: list[str] = params["values"]["args"]

    return self.driver.run(*[TextArtifact(arg) for arg in args])