Skip to content

Commit

Permalink
Fix BaseTask.full_context functioning when structure not set
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Oct 8, 2024
1 parent a775fc8 commit da09888
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `RuleMixin` no longer prevents setting `rulesets` _and_ `rules` at the same time.
- `PromptTask` will merge in its Structure's Rulesets and Rules.
- `PromptTask` not checking whether Structure was set before building Prompt Stack.
- `BaseTask.full_context` context being empty when not connected to a Structure.

## [0.32.0] - 2024-09-17

Expand Down
9 changes: 3 additions & 6 deletions griptape/tasks/base_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,8 @@ def run(self) -> BaseArtifact: ...

@property
def full_context(self) -> dict[str, Any]:
context = self.context
if self.structure is not None:
structure_context = self.structure.context(self)
context.update(self.structure.context(self))

structure_context.update(self.context)

return structure_context
else:
return {}
return context
5 changes: 5 additions & 0 deletions tests/unit/tasks/test_base_text_input_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ def test_full_context(self):
parent = MockTextInputTask("parent")
subtask = MockTextInputTask("test", context={"foo": "bar"})
child = MockTextInputTask("child")

assert parent.full_context == {}
assert subtask.full_context == {"foo": "bar"}
assert child.full_context == {}

pipeline = Pipeline()

pipeline.add_tasks(parent, subtask, child)
Expand Down

0 comments on commit da09888

Please sign in to comment.