Updating docs

This commit is contained in:
João Moura
2024-08-11 15:04:45 -03:00
parent 7b63b6f485
commit a17fa70b1b
20 changed files with 153 additions and 118 deletions

View File

@@ -7,9 +7,10 @@ description: Learn how to use conditional tasks in a crewAI kickoff
Conditional Tasks in crewAI allow for dynamic workflow adaptation based on the outcomes of previous tasks. This powerful feature enables crews to make decisions and execute tasks selectively, enhancing the flexibility and efficiency of your AI-driven processes.
## Example Usage
```python
from typing import List
from pydantic import BaseModel
from crewai import Agent, Crew
from crewai.tasks.conditional_task import ConditionalTask
@@ -17,11 +18,10 @@ from crewai.tasks.task_output import TaskOutput
from crewai.task import Task
from crewai_tools import SerperDevTool
# Define a condition function for the conditional task
# if false task will be skipped, true, then execute task
def is_data_missing(output: TaskOutput) -> bool:
return len(output.pydantic.events) < 10: # this will skip this task
return len(output.pydantic.events) < 10 # this will skip this task
# Define the agents
data_fetcher_agent = Agent(
@@ -46,11 +46,9 @@ summary_generator_agent = Agent(
verbose=True,
)
class EventOutput(BaseModel):
events: List[str]
task1 = Task(
description="Fetch data about events in San Francisco using Serper tool",
expected_output="List of 10 things to do in SF this week",
@@ -64,7 +62,7 @@ conditional_task = ConditionalTask(
fetch more events using Serper tool so that
we have a total of 10 events in SF this week..
""",
expected_output="List of 10 Things to do in SF this week ",
expected_output="List of 10 Things to do in SF this week",
condition=is_data_missing,
agent=data_processor_agent,
)
@@ -80,8 +78,10 @@ crew = Crew(
agents=[data_fetcher_agent, data_processor_agent, summary_generator_agent],
tasks=[task1, conditional_task, task3],
verbose=True,
planning=True # Enable planning feature
)
# Run the crew
result = crew.kickoff()
print("results", result)
```
```