Skip to content

Code execution task

CodeExecutionTask

Bases: BaseTextInputTask

Source code in griptape/griptape/tasks/code_execution_task.py
@define
class CodeExecutionTask(BaseTextInputTask):
    run_fn: Callable[[CodeExecutionTask], BaseArtifact] = field(kw_only=True)

    def run(self) -> BaseArtifact:
        try:
            return self.run_fn(self)
        except Exception as e:
            return ErrorArtifact(f"error during Code Execution Task: {e}")

run_fn: Callable[[CodeExecutionTask], BaseArtifact] = field(kw_only=True) class-attribute instance-attribute

run()

Source code in griptape/griptape/tasks/code_execution_task.py
def run(self) -> BaseArtifact:
    try:
        return self.run_fn(self)
    except Exception as e:
        return ErrorArtifact(f"error during Code Execution Task: {e}")