Skip to content
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

Automatically resolve tasks within flows #36

Merged
merged 1 commit into from
May 15, 2024
Merged

Automatically resolve tasks within flows #36

merged 1 commit into from
May 15, 2024

Conversation

jlowin
Copy link
Member

@jlowin jlowin commented May 15, 2024

This PR moves flow/task decorators to their own module, and adds functionality to automatically run and resolve and tasks created/returned by a flow function.

from controlflow import Task, flow


@flow
def book_ideas():
    genre = Task("pick a genre", str)
    ideas = Task(
        "generate three short ideas for a book",
        list[str],
        context=dict(genre=genre),
    )
    abstract = Task(
        "pick one idea and write an abstract",
        str,
        context=dict(ideas=ideas, genre=genre),
    )
    title = Task(
        "pick a title",
        str,
        context=dict(abstract=abstract),
    )

    return dict(genre=genre, ideas=ideas, abstract=abstract, title=title)


if __name__ == "__main__":
    result = book_ideas()
    print(result)

@jlowin jlowin merged commit 06f7ac5 into main May 15, 2024
1 of 3 checks passed
@jlowin jlowin deleted the flow branch May 15, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant