forked from griptape-ai/griptape
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parallel action execution for
ToolkitTask
(griptape-ai#673)
- Loading branch information
Showing
38 changed files
with
772 additions
and
646 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from __future__ import annotations | ||
from attrs import define | ||
from .base_actions_subtask_event import BaseActionsSubtaskEvent | ||
|
||
|
||
@define | ||
class FinishActionsSubtaskEvent(BaseActionsSubtaskEvent): | ||
... |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from __future__ import annotations | ||
from attrs import define | ||
from .base_actions_subtask_event import BaseActionsSubtaskEvent | ||
|
||
|
||
@define | ||
class StartActionsSubtaskEvent(BaseActionsSubtaskEvent): | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from __future__ import annotations | ||
from typing import TYPE_CHECKING | ||
from abc import abstractmethod | ||
from attr import define | ||
from schema import Schema, Literal | ||
|
||
if TYPE_CHECKING: | ||
from griptape.memory import TaskMemory | ||
from griptape.tools import BaseTool | ||
from griptape.tasks import ActionsSubtask | ||
|
||
|
||
@define(slots=False) | ||
class ActionsSubtaskOriginMixin: | ||
@abstractmethod | ||
def find_tool(self, tool_name: str) -> BaseTool: | ||
... | ||
|
||
@abstractmethod | ||
def find_memory(self, memory_name: str) -> TaskMemory: | ||
... | ||
|
||
@abstractmethod | ||
def find_subtask(self, subtask_id: str) -> ActionsSubtask: | ||
... | ||
|
||
@abstractmethod | ||
def add_subtask(self, subtask: ActionsSubtask) -> ActionsSubtask: | ||
... | ||
|
||
@abstractmethod | ||
def actions_schema(self) -> dict: | ||
... | ||
|
||
def _actions_schema_for_tools(self, tools: list[BaseTool]) -> dict: | ||
action_schemas = [] | ||
|
||
for tool in tools: | ||
for activity_schema in tool.activity_schemas(): | ||
action_schema = activity_schema.schema | ||
output_label_key = Literal( | ||
"output_label", description="Action label that can later be used to identify action output" | ||
) | ||
|
||
action_schema[output_label_key] = str | ||
|
||
action_schemas.append(action_schema) | ||
|
||
actions_schema = Schema( | ||
description="JSON schema for an array of actions to be executed in parallel.", schema=action_schemas | ||
) | ||
|
||
return actions_schema.json_schema("Actions Schema") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.