datamongus
02/07/2025, 9:56 PMcf.task
and cf.run
Marvin
02/07/2025, 9:56 PMcf.task
and cf.run
serve different purposes:
- cf.task
: This is a decorator used to define tasks in a structured way. Tasks are the fundamental building blocks of AI workflows in ControlFlow, representing discrete, well-defined objectives. They are checkpoints where you can validate outputs to ensure alignment with application requirements. Using the @task
decorator is less common and less flexible than using the Task class directly, but it allows you to create tasks by decorating functions.
- cf.run
: This function is used to create and run a task in a single step. It simplifies the process by combining task creation and execution, accepting the same arguments as creating a Task directly. It's a more straightforward approach for executing tasks quickly.
For more detailed insights, you can refer to the ControlFlow tasks documentation and the quickstart guide.