Skip to content

Commit

Permalink
Add default to CodExecutionTask
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed May 2, 2024
1 parent ad3e67a commit 72e975c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `GriptapeCloudStructureRunClient` Tool for invoking Griptape Cloud Structure Run APIs.
- `GriptapeStructureRunClient` for running Structures from within a `ToolTask` or `ToolkitTask`.
- `StructureRunTask` for running Structures as a Task from within another Structure.
- Default `run_fn` to `CodeExecutionTask`, making it a suitable no-op Task.

### Changed
- **BREAKING**: Secret fields (ex: api_key) removed from serialized Drivers.
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/multi-agent-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from griptape.drivers import WebhookEventListenerDriver
from griptape.events import EventListener, FinishStructureRunEvent
from griptape.rules import Rule, Ruleset
from griptape.structures import Agent, Workflow
from griptape.tasks import NoOpTask, StructureRunTask
from griptape.tasks import CodeExecutionTask, StructureRunTask
from griptape.tools import (
TaskMemoryClient,
WebScraper,
Expand Down Expand Up @@ -145,7 +145,7 @@ if __name__ == "__main__":
structure_to_run=build_researcher(),
),
)
end_task = team.add_task(NoOpTask())
end_task = team.add_task(CodeExecutionTask()) # Placeholder task to end the Workflow. By default this is a no-op.
team.insert_tasks(
research_task,
[
Expand Down
4 changes: 2 additions & 2 deletions griptape/tasks/code_execution_task.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from __future__ import annotations
from attr import define, field
from attr import define, field, Factory
from griptape.artifacts import BaseArtifact, ErrorArtifact
from griptape.tasks import BaseTextInputTask
from typing import Callable


@define
class CodeExecutionTask(BaseTextInputTask):
run_fn: Callable[[CodeExecutionTask], BaseArtifact] = field(kw_only=True)
run_fn: Callable[[CodeExecutionTask], BaseArtifact] = field(default=Factory(lambda: lambda task: task))

def run(self) -> BaseArtifact:
try:
Expand Down

0 comments on commit 72e975c

Please sign in to comment.