diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c392dc10..85bd6ddd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **BREAKING**: Removed `ImageQueryTask`, use `PromptTask` instead. - **BREAKING**: Updated `ImageQueryTool.image_query_driver` to `ImageQueryTool.prompt_driver`. - **BREAKING**: Updated `numpy` to `~2.0.2` and `pandas` to `^2.2`. +- **BREAKING**: Renamed `StructureRunTask.driver` to `StructureRunTask.structure_run_driver`. +- **BREAKING**: Renamed `StructureRunTool.driver` to `StructureRunTool.structure_run_driver`. - File Manager Driver path logic has been improved. - `LocalFileManagerDriver.workdir` can now be a relative path or absolute path. Relative paths will be prefixed with the current working directory. - `AmazonS3FileManagerDriver.workdir` can now be a relative path or absolute path. Relative paths will be prefixed with `/`. diff --git a/MIGRATION.md b/MIGRATION.md index 7c795a349..c01c26b28 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -253,6 +253,32 @@ pipeline = Pipeline( pipeline.run("Describe the weather in the image") ``` +### Renamed `StructureRunTask.driver`/`StructureRunTool.driver` to `StructureRunTask.structure_run_driver`/`StructureRunTool.structure_run_driver` + +`StructureRunTask.driver` and `StructureRunTool.driver` have been renamed to `StructureRunTask.structure_run_driver` and `StructureRunTool.structure_run_driver` respectively. + +#### Before + +```python +StructureRunTask( + driver=LocalStructureRunDriver(), +) +StructureRunTool( + driver=LocalStructureRunDriver(), +) +``` + +#### After + +```python +StructureRunTask( + structure_run_driver=LocalStructureRunDriver(), +) +StructureRunTool( + structure_run_driver=LocalStructureRunDriver(), +) +``` + ## 0.33.X to 0.34.X ### `AnthropicDriversConfig` Embedding Driver diff --git a/docs/examples/src/multi_agent_workflow_1.py b/docs/examples/src/multi_agent_workflow_1.py index ea880435a..3c8de2496 100644 --- a/docs/examples/src/multi_agent_workflow_1.py +++ b/docs/examples/src/multi_agent_workflow_1.py @@ -132,7 +132,7 @@ def build_writer(role: str, goal: str, backstory: str) -> Agent: Pinpoint major trends, breakthroughs, and their implications for various industries.""", ), id="research", - driver=LocalStructureRunDriver( + structure_run_driver=LocalStructureRunDriver( create_structure=build_researcher, ), ), @@ -149,7 +149,7 @@ def build_writer(role: str, goal: str, backstory: str) -> Agent: Insights: {{ parent_outputs["research"] }}""", ), - driver=LocalStructureRunDriver( + structure_run_driver=LocalStructureRunDriver( create_structure=lambda writer=writer: build_writer( role=writer["role"], goal=writer["goal"], diff --git a/docs/griptape-framework/drivers/src/structure_run_drivers_1.py b/docs/griptape-framework/drivers/src/structure_run_drivers_1.py index 5fc5b29fe..5c746da8a 100644 --- a/docs/griptape-framework/drivers/src/structure_run_drivers_1.py +++ b/docs/griptape-framework/drivers/src/structure_run_drivers_1.py @@ -27,13 +27,13 @@ def build_joke_rewriter() -> Agent: joke_coordinator = Pipeline( tasks=[ StructureRunTask( - driver=LocalStructureRunDriver( + structure_run_driver=LocalStructureRunDriver( create_structure=build_joke_teller, ), ), StructureRunTask( ("Rewrite this joke: {{ parent_output }}",), - driver=LocalStructureRunDriver( + structure_run_driver=LocalStructureRunDriver( create_structure=build_joke_rewriter, ), ), diff --git a/docs/griptape-framework/drivers/src/structure_run_drivers_2.py b/docs/griptape-framework/drivers/src/structure_run_drivers_2.py index bec40c6ee..4840aa6f3 100644 --- a/docs/griptape-framework/drivers/src/structure_run_drivers_2.py +++ b/docs/griptape-framework/drivers/src/structure_run_drivers_2.py @@ -14,7 +14,7 @@ tasks=[ StructureRunTask( ("Think of a question related to Retrieval Augmented Generation.",), - driver=LocalStructureRunDriver( + structure_run_driver=LocalStructureRunDriver( create_structure=lambda: Agent( rules=[ Rule( @@ -29,7 +29,7 @@ ), StructureRunTask( ("{{ parent_output }}",), - driver=GriptapeCloudStructureRunDriver( + structure_run_driver=GriptapeCloudStructureRunDriver( base_url=base_url, api_key=api_key, structure_id=structure_id, diff --git a/docs/griptape-framework/structures/src/tasks_16.py b/docs/griptape-framework/structures/src/tasks_16.py index 332187a00..20fd7ac4a 100644 --- a/docs/griptape-framework/structures/src/tasks_16.py +++ b/docs/griptape-framework/structures/src/tasks_16.py @@ -112,7 +112,7 @@ def build_writer() -> Agent: """Perform a detailed examination of the newest developments in AI as of 2024. Pinpoint major trends, breakthroughs, and their implications for various industries.""", ), - driver=LocalStructureRunDriver(create_structure=build_researcher), + structure_run_driver=LocalStructureRunDriver(create_structure=build_researcher), ), StructureRunTask( ( @@ -122,7 +122,7 @@ def build_writer() -> Agent: Keep the tone appealing and use simple language to make it less technical.""", "{{parent_output}}", ), - driver=LocalStructureRunDriver(create_structure=build_writer), + structure_run_driver=LocalStructureRunDriver(create_structure=build_writer), ), ], ) diff --git a/docs/griptape-tools/official-tools/src/structure_run_tool_1.py b/docs/griptape-tools/official-tools/src/structure_run_tool_1.py index 575092ce6..482bb77c8 100644 --- a/docs/griptape-tools/official-tools/src/structure_run_tool_1.py +++ b/docs/griptape-tools/official-tools/src/structure_run_tool_1.py @@ -10,7 +10,7 @@ structure_run_tool = StructureRunTool( description="RAG Expert Agent - Structure to invoke with natural language queries about the topic of Retrieval Augmented Generation", - driver=GriptapeCloudStructureRunDriver( + structure_run_driver=GriptapeCloudStructureRunDriver( base_url=base_url, api_key=api_key, structure_id=structure_id, diff --git a/griptape/tasks/structure_run_task.py b/griptape/tasks/structure_run_task.py index db5f8bc49..1120d4f13 100644 --- a/griptape/tasks/structure_run_task.py +++ b/griptape/tasks/structure_run_task.py @@ -17,13 +17,13 @@ class StructureRunTask(PromptTask): """Task to run a Structure. Attributes: - driver: Driver to run the Structure. + structure_run_driver: Driver to run the Structure. """ - driver: BaseStructureRunDriver = field(kw_only=True) + structure_run_driver: BaseStructureRunDriver = field(kw_only=True) def try_run(self) -> BaseArtifact: if isinstance(self.input, ListArtifact): - return self.driver.run(*self.input.value) + return self.structure_run_driver.run(*self.input.value) else: - return self.driver.run(self.input) + return self.structure_run_driver.run(self.input) diff --git a/griptape/tools/structure_run/tool.py b/griptape/tools/structure_run/tool.py index 317d5482e..d2fc0e566 100644 --- a/griptape/tools/structure_run/tool.py +++ b/griptape/tools/structure_run/tool.py @@ -19,11 +19,11 @@ class StructureRunTool(BaseTool): Attributes: description: A description of what the Structure does. - driver: Driver to run the Structure. + structure_run_driver: Driver to run the Structure. """ description: str = field(kw_only=True) - driver: BaseStructureRunDriver = field(kw_only=True) + structure_run_driver: BaseStructureRunDriver = field(kw_only=True) @activity( config={ @@ -40,4 +40,4 @@ class StructureRunTool(BaseTool): def run_structure(self, params: dict) -> BaseArtifact: args: list[str] = params["values"]["args"] - return self.driver.run(*[TextArtifact(arg) for arg in args]) + return self.structure_run_driver.run(*[TextArtifact(arg) for arg in args]) diff --git a/tests/unit/drivers/structure_run/test_local_structure_run_driver.py b/tests/unit/drivers/structure_run/test_local_structure_run_driver.py index 4be4caf77..b41ba354e 100644 --- a/tests/unit/drivers/structure_run/test_local_structure_run_driver.py +++ b/tests/unit/drivers/structure_run/test_local_structure_run_driver.py @@ -11,7 +11,7 @@ def test_run(self): pipeline = Pipeline() driver = LocalStructureRunDriver(create_structure=lambda: Agent()) - task = StructureRunTask(driver=driver) + task = StructureRunTask(structure_run_driver=driver) pipeline.add_task(task) @@ -23,7 +23,7 @@ def test_run_with_env(self, mock_config): mock_config.drivers_config.prompt_driver = MockPromptDriver(mock_output=lambda _: os.environ["KEY"]) agent = Agent() driver = LocalStructureRunDriver(create_structure=lambda: agent, env={"KEY": "value"}) - task = StructureRunTask(driver=driver) + task = StructureRunTask(structure_run_driver=driver) pipeline.add_task(task) diff --git a/tests/unit/tasks/test_structure_run_task.py b/tests/unit/tasks/test_structure_run_task.py index 1df8ca8bf..bee659368 100644 --- a/tests/unit/tasks/test_structure_run_task.py +++ b/tests/unit/tasks/test_structure_run_task.py @@ -12,7 +12,7 @@ def test_run_single_input(self, mock_config): pipeline = Pipeline() driver = LocalStructureRunDriver(create_structure=lambda: agent) - task = StructureRunTask(driver=driver) + task = StructureRunTask(structure_run_driver=driver) pipeline.add_task(task) @@ -25,7 +25,7 @@ def test_run_multiple_inputs(self, mock_config): pipeline = Pipeline() driver = LocalStructureRunDriver(create_structure=lambda: agent) - task = StructureRunTask(input=["foo", "bar", "baz"], driver=driver) + task = StructureRunTask(input=["foo", "bar", "baz"], structure_run_driver=driver) pipeline.add_task(task) diff --git a/tests/unit/tools/test_structure_run_tool.py b/tests/unit/tools/test_structure_run_tool.py index 8b581103e..7cfc0af83 100644 --- a/tests/unit/tools/test_structure_run_tool.py +++ b/tests/unit/tools/test_structure_run_tool.py @@ -10,7 +10,9 @@ class TestStructureRunTool: def client(self): agent = Agent() - return StructureRunTool(description="foo bar", driver=LocalStructureRunDriver(create_structure=lambda: agent)) + return StructureRunTool( + description="foo bar", structure_run_driver=LocalStructureRunDriver(create_structure=lambda: agent) + ) def test_run_structure(self, client): assert client.run_structure({"values": {"args": "foo bar"}}).value == "mock output"