Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ControlFlowTask #913

Closed
wants to merge 2 commits into from
Closed

Add ControlFlowTask #913

wants to merge 2 commits into from

Conversation

vachillo
Copy link
Member

@vachillo vachillo commented Jun 28, 2024

Copy link

codecov bot commented Jul 1, 2024

@vachillo vachillo force-pushed the control_flow branch 3 times, most recently from 066e451 to 40b096a Compare July 3, 2024 18:47
@@ -10,11 +10,13 @@ class BooleanArtifact(BaseArtifact):
meta: dict[str, Any] = field(factory=dict, kw_only=True, metadata={"serializable": True})

@classmethod
def parse_bool(cls, value: Union[str, bool]) -> BooleanArtifact:
def parse_bool(cls, value: Union[str, bool, TextArtifact]) -> BooleanArtifact:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be named from_bool for consistency with other similar methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • a bool is one of the possible inputs, so from_bool isn't really accurate.
  • i wanted to convey the fact that its going to actually evaluate the literal text in the string, rather than just coerce the input type to a bool type.

@@ -10,11 +10,13 @@ class BooleanArtifact(BaseArtifact):
meta: dict[str, Any] = field(factory=dict, kw_only=True, metadata={"serializable": True})

@classmethod
def parse_bool(cls, value: Union[str, bool]) -> BooleanArtifact:
def parse_bool(cls, value: Union[str, bool, TextArtifact]) -> BooleanArtifact:
"""
Convert a string literal or bool to a BooleanArtifact. The string must be either "true" or "false" with any casing.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update docstring to mention text artifact.

Comment on lines 18 to 24
self.structure.meta_memory.add_entry(
ControlFlowMetaEntry(
input_tasks=[parent.id for parent in self.parents],
output_tasks=[child.id for child in filter(lambda child: not child.is_finished(), self.children)],
output=self.output,
)
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding to Meta Memory at all? What does the LLM need to know about the branch decisions?
Also, there has been talk of removing Meta Memory entirely, I'm not sure we should rely on it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to have some mechanism of storing the "decision" of the control flow.



@define
class TaskArtifact(ControlFlowArtifact):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I feel about this artifact. And in a fully declarative Workflow it may be impossible to return a Task object.

Can we just operate with Task ids in a TextArtifact?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just used to return the input of the task. and it will always return the tasks because it pulls directly from the structure

from griptape.tasks import BaseTask


class BooleanControlFlowTask(BaseControlFlowTask):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need to reinvent boolean logic in its own Task. Users can implement this themselves in their control_flow_fn



@define
class ChoiceControlFlowTask(BaseControlFlowTask):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a dedicated Task for this? What if we added control_flow_fn to BaseTask?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

future proof if there is other types of control flow tasks

@collindutter
Copy link
Member

Slight variation to this implementation: dev...feature/branch-task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for branching in Workflows
2 participants