-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from jlowin/run
Overhaul task / agent running
- Loading branch information
Showing
13 changed files
with
430 additions
and
249 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from control_flow import Agent, Task | ||
|
||
writer = Agent(name="writer") | ||
editor = Agent(name="editor", instructions="you always find at least one problem") | ||
critic = Agent(name="critic") | ||
|
||
|
||
# ai tasks: | ||
# - automatically supply context from kwargs | ||
# - automatically wrap sub tasks in parent | ||
# - automatically iterate over sub tasks if they are all completed but the parent isn't? | ||
|
||
|
||
def write_paper(topic: str) -> str: | ||
""" | ||
Write a paragraph on the topic | ||
""" | ||
draft = Task( | ||
"produce a 3-sentence draft on the topic", | ||
str, | ||
agents=[writer], | ||
context=dict(topic=topic), | ||
) | ||
edits = Task("edit the draft", str, agents=[editor], depends_on=[draft]) | ||
critique = Task("is it good enough?", bool, agents=[critic], depends_on=[edits]) | ||
return critique | ||
|
||
|
||
task = write_paper("AI and the future of work") | ||
task.run() |
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
Oops, something went wrong.