Skip to content

Commit

Permalink
Add Workflow.outputs (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter authored Sep 27, 2024
1 parent c1bb81a commit e16d23b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- `Workflow.input_tasks` and `Workflow.output_tasks` to access the input and output tasks of a Workflow.
- Ability to pass nested list of `Tasks` to `Structure.tasks` allowing for more complex declarative Structure definitions.


## Added
- `Workflow.input_tasks` and `Workflow.output_tasks` to access the input and output tasks of a Workflow.
- Ability to pass nested list of `Tasks` to `Structure.tasks` allowing for more complex declarative Structure definitions.
- Parameter `pipeline_task` on `HuggingFacePipelinePromptDriver` for creating different types of `Pipeline`s.
- `TavilyWebSearchDriver` to integrate Tavily's web search capabilities.
- `Workflow.outputs` to access the outputs of a Workflow.

### Changed
- **BREAKING**: Renamed parameters on several classes to `client`:
Expand Down
5 changes: 5 additions & 0 deletions griptape/structures/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from griptape.structures import Structure

if TYPE_CHECKING:
from griptape.artifacts import BaseArtifact
from griptape.tasks import BaseTask


Expand All @@ -33,6 +34,10 @@ def input_tasks(self) -> list[BaseTask]:
def output_tasks(self) -> list[BaseTask]:
return [task for task in self.tasks if not task.children]

@property
def outputs(self) -> list[BaseArtifact]:
return [task.output.value for task in self.output_tasks if task.output is not None]

def add_task(self, task: BaseTask) -> BaseTask:
if (existing_task := self.try_find_task(task.id)) is not None:
return existing_task
Expand Down
9 changes: 9 additions & 0 deletions tests/unit/structures/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,15 @@ def test_input_tasks(self):

assert workflow.input_tasks == [parent]

def test_outputs(self):
workflow = Workflow(tasks=[PromptTask("parent") for _ in range(3)])

assert workflow.outputs == []

workflow.run()

assert workflow.outputs == ["mock output"] * 3

@staticmethod
def _validate_topology_1(workflow) -> None:
assert len(workflow.tasks) == 4
Expand Down

0 comments on commit e16d23b

Please sign in to comment.