Skip to content

Commit

Permalink
Use factory in example (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter authored May 6, 2024
1 parent 57a4a29 commit 73cc9a8
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions docs/griptape-framework/drivers/structure-run-drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
]
Expand Down

0 comments on commit 73cc9a8

Please sign in to comment.