From 708b17cec787df46a12981b3dc7d4194d2e501af Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Mon, 6 May 2024 10:32:48 -0700 Subject: [PATCH] Use factory in example --- .../drivers/structure-run-drivers.md | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/docs/griptape-framework/drivers/structure-run-drivers.md b/docs/griptape-framework/drivers/structure-run-drivers.md index 9c1441608..c2b94190c 100644 --- a/docs/griptape-framework/drivers/structure-run-drivers.md +++ b/docs/griptape-framework/drivers/structure-run-drivers.md @@ -12,33 +12,39 @@ from griptape.rules import Rule from griptape.structures import Agent, Pipeline from griptape.tasks import StructureRunTask -joke_teller = Agent( - rules=[ - Rule( - value="You are very funny.", - ) - ], -) - -joke_rewriter = Agent( - rules=[ - Rule( - value="You are the editor of a joke book. But you only speak in riddles", - ) - ], -) +def build_joke_teller(): + joke_teller = Agent( + rules=[ + Rule( + value="You are very funny.", + ) + ], + ) + + return joke_teller + +def build_joke_rewriter(): + joke_rewriter = Agent( + rules=[ + Rule( + value="You are the editor of a joke book. But you only speak in riddles", + ) + ], + ) + + return joke_rewriter joke_coordinator = Pipeline( tasks=[ StructureRunTask( driver=LocalStructureRunDriver( - structure_factory_fn=lambda: joke_teller, + structure_factory_fn=build_joke_teller, ), ), StructureRunTask( ("Rewrite this joke: {{ parent_output }}",), driver=LocalStructureRunDriver( - structure_factory_fn=lambda: joke_rewriter, + structure_factory_fn=build_joke_rewriter, ), ), ]