-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
117 lines (94 loc) · 5.12 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
from crewai import Task
from textwrap import dedent
"""
Creating Tasks Cheat Sheet:
- Begin with the end in mind. Identify the specific outcome your tasks are aiming to achieve.
- Break down the outcome into actionable tasks, assigning each task to the appropriate agent.
- Ensure tasks are descriptive, providing clear instructions and expected deliverables.
Goal:
- Develop a detailed itinerary, including city selection, attractions, and practical travel advice.
Key Steps for Task Creation:
1. Identify the Desired Outcome: Define what success looks like for your project.
- A detailed 7 day travel itenerary.
2. Task Breakdown: Divide the goal into smaller, manageable tasks that agents can execute.
- Itenerary Planning: develop a detailed plan for each day of the trip.
- City Selection: Analayze and pick the best cities to visit.
- Local Tour Guide: Find a local expert to provide insights and recommendations.
3. Assign Tasks to Agents: Match tasks with agents based on their roles and expertise.
4. Task Description Template:
- Use this template as a guide to define each task in your CrewAI application.
- This template helps ensure that each task is clearly defined, actionable, and aligned with the specific goals of your project.
Template:
---------
def [task_name](self, agent, [parameters]):
return Task(description=dedent(f'''
**Task**: [Provide a concise name or summary of the task.]
**Description**: [Detailed description of what the agent is expected to do, including actionable steps and expected outcomes. This should be clear and direct, outlining the specific actions required to complete the task.]
**Parameters**:
- [Parameter 1]: [Description]
- [Parameter 2]: [Description]
... [Add more parameters as needed.]
**Note**: [Optional section for incentives or encouragement for high-quality work. This can include tips, additional context, or motivations to encourage agents to deliver their best work.]
'''), agent=agent)
"""
class TravelTasks:
def __tip_section(self):
return "If you do your BEST WORK, I'll give you a $10,000 commission!"
def plan_itinerary(self, agent, city, travel_dates, interests):
return Task(
description=dedent(
f"""
**Task**: Develop a 7-Day Travel Itinerary
**Description**: Expand the city guide into a full 7-day travel itinerary with detailed
per-day plans, including weather forecasts, places to eat, packing suggestions,
and a budget breakdown. You MUST suggest actual places to visit, actual hotels to stay,
and actual restaurants to go to. This itinerary should cover all aspects of the trip,
from arrival to departure, integrating the city guide information with practical travel logistics.
**Parameters**:
- City: {city}
- Trip Date: {travel_dates}
- Traveler Interests: {interests}
**Note**: {self.__tip_section()}
"""
),
agent=agent,
)
def identify_city(self, agent, origin, cities, interests, travel_dates):
return Task(
description=dedent(
f"""
**Task**: Identify the Best City for the Trip
**Description**: Analyze and select the best city for the trip based on specific
criteria such as weather patterns, seasonal events, and travel costs.
This task involves comparing multiple cities, considering factors like current weather
conditions, upcoming cultural or seasonal events, and overall travel expenses.
Your final answer must be a detailed report on the chosen city,
including actual flight costs, weather forecast, and attractions.
**Parameters**:
- Origin: {origin}
- Cities: {cities}
- Interests: {interests}
- Travel Date: {travel_dates}
**Note**: {self.__tip_section()}
"""
),
agent=agent,
)
def gather_city_info(self, agent, city, travel_dates, interests):
return Task(
description=dedent(
f"""
**Task**: Gather In-depth City Guide Information
**Description**: Compile an in-depth guide for the selected city, gathering information about
key attractions, local customs, special events, and daily activity recommendations.
This guide should provide a thorough overview of what the city has to offer, including
hidden gems, cultural hotspots, must-visit landmarks, weather forecasts, and high-level costs.
**Parameters**:
- Cities: {city}
- Interests: {interests}
- Travel Date: {travel_dates}
**Note**: {self.__tip_section()}
"""
),
agent=agent,
)