-
Notifications
You must be signed in to change notification settings - Fork 175
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 structure run tool/task #767
Conversation
46c4d0c
to
70eb6db
Compare
CHANGELOG.md
Outdated
@@ -24,7 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
- `AmazonS3FileManagerDriver` for managing files on Amazon S3. | |||
- `MediaArtifact` as a base class for `ImageArtifact` and future media Artifacts. | |||
- Optional `exception` field to `ErrorArtifact`. | |||
- `GriptapeCloudStructureRunClient` tool for invoking Griptape Cloud Structure Run APIs. | |||
- `GriptapeCloudStructureRunClient` Tool for invoking Griptape Cloud Structure Run APIs. | |||
- `GriptapeStructureRunClient` Tool for through a Tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tool for RUNNING a Structure from within a Structure?
In this example we implement a multi-agent Workflow we have a single "Researcher" Agent that conducts research on a topic, and then fans out to multiple "Writer" Agents to write blog posts based on the research. | ||
|
||
By splitting up our workloads across multiple Structures, we can parallelize the work and leverage the strengths of each Agent. The Researcher can focus on gathering data and insights, while the Writers can focus on crafting engaging narratives. | ||
Additionally, this opens us up to the possibility of having each Agent run on a separate machine or container, allowing us to scale our Workflow as needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be coy here; let's talk about "we can solve these in parallel using Griptape Cloud managed Structures to solve these simultaneously and get it faster" or whatever.
with open(f"{Path(__file__).parent}/writers.json", "r") as f: | ||
writers = json.loads(f.read()) | ||
|
||
# Build the crew |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...team...?
ac94922
to
0ac5bc9
Compare
griptape/tasks/structure_run_task.py
Outdated
"""Task to run a Structure. | ||
|
||
Attributes: | ||
structure_to_run: Structure to run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awkward field name but structure
is already taken by BaseTask
. Open to suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target_structure
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
""" | ||
|
||
description: str = field(kw_only=True) | ||
structure: Structure = field(kw_only=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this consistent with the awkward structure_to_run
on the Task?
68fce49
to
96005fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job!
I really like seeing the doc examples in the same PR (and its also nice that they just happen to show up at the beginning of the list the files).
df075cb
to
fd616f3
Compare
fd616f3
to
0196143
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qs only.
CHANGELOG.md
Outdated
- `GriptapeCloudStructureRunClient` tool for invoking Griptape Cloud Structure Run APIs. | ||
- `StructureRunClient` for running other Structures via a Tool. | ||
- `StructureRunTask` for running Structures as a Task from within another Structure. | ||
- `GriptapeCloudStructureRunDriver` for running Structures in the Griptape Cloud. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this ONLY work for Cloud or will it work for the emulator as well?
@@ -23,7 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
- `AmazonS3FileManagerDriver` for managing files on Amazon S3. | |||
- `MediaArtifact` as a base class for `ImageArtifact` and future media Artifacts. | |||
- Optional `exception` field to `ErrorArtifact`. | |||
- `GriptapeCloudStructureRunClient` tool for invoking Griptape Cloud Structure Run APIs. | |||
- `StructureRunClient` for running other Structures via a Tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ugh why can't it end with Tool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Named it this way for consistency TaskMemoryClient
, another Tool that interacts directly with the framework. Agree that it's not ideal but it's at least consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boo but OK. In the future, we don't let consistency hold us back :)
Identify key trends, breakthrough technologies, and potential industry impacts.""", | ||
), | ||
driver=LocalStructureRunDriver( | ||
structure_factory_fn=lambda: researcher, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Learning from the pitfall Jason fell into when reusing the same instance for multiple runs, maybe all the examples should use actually factory functions that return new instances. That way if someone starts out with one of our examples, they'll be on the right path from the beginning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, updated.
"""Conduct a comprehensive analysis of the latest advancements in AI in 2024. | ||
Identify key trends, breakthrough technologies, and potential industry impacts.""", | ||
id="research", | ||
target_structure=build_researcher(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to LocalStructureRunDriver
, StructureRunTask
should accept a structure_factory_fn
instead of an actual Structure
instance to avoid the pitfalls of shared state between concurrent runs, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually a mistake in the examples, target_structure
is no longer a field. The Tool takes a Driver just like the Task.
958a0b4
to
9bbbfd3
Compare
9bbbfd3
to
01732fa
Compare
- **BREADKING**: Removed `mime_type` field from `ImageArtifact`. `mime_type` is now a property constructed using the Artifact type and `format` field. | ||
- **BREAKING**: Removed `mime_type` field from `ImageArtifact`. `mime_type` is now a property constructed using the Artifact type and `format` field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long live Bread King.
@@ -23,7 +23,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
- `AmazonS3FileManagerDriver` for managing files on Amazon S3. | |||
- `MediaArtifact` as a base class for `ImageArtifact` and future media Artifacts. | |||
- Optional `exception` field to `ErrorArtifact`. | |||
- `GriptapeCloudStructureRunClient` tool for invoking Griptape Cloud Structure Run APIs. | |||
- `StructureRunClient` for running other Structures via a Tool. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boo but OK. In the future, we don't let consistency hold us back :)
tasks=[ | ||
StructureRunTask( | ||
driver=LocalStructureRunDriver( | ||
structure_factory_fn=lambda: joke_teller, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this one also return a new instance, for similar reasons to my other comment?
Added
StructureRunClient
for running other Griptapes via a Tool.StructureRunTask
for running Structures as a Task from within another Structure.GriptapeCloudStructureRunDriver
for running Structures in the Griptape Cloud.LocalStructureRunDriver
for running Structures in the same runtime environment as the code that is running the Structure.run_fn
toCodeExecutionTask
, making it a suitable no-op Task.📚 Documentation preview 📚: https://griptape--767.org.readthedocs.build//767/