Spaces:
Sleeping
Sleeping
# To know more about the Task class, visit: https://docs.crewai.com/concepts/tasks | |
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 per-day plans to avoid jet lag during and after travel. | |
Plan will be done for 3 days before travel, during travel, and 3 days | |
Key Steps for Task Creation: | |
1. Identify the Desired Outcome: Define what success looks like for your project. | |
- Develop a detailed per-day plan to avoid jet lag during and after travel. | |
2. Task Breakdown: Divide the goal into smaller, manageable tasks that agents can execute. | |
- Sleep Schedule: Create a sleep schedule for the user based on their travel itinerary. | |
- Diet Plan: Create a diet plan for the user based on their travel itinerary. | |
- Fitness Routine: Recommend exercise routines for the user based on their travel itinerary. | |
- Plan Travel: Develop a detailed per-day plan of sleep, diet and exercise for 3 days before travel, during travel, and 3 days to avoid jet lag. | |
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 sleep_schedule(self, agent, origin_city, destination_city, date_of_departure, date_of_return, departure_flight, return_flight): | |
return Task( | |
description=dedent( | |
f""" | |
**Task**: Create a sleep schedule for the user based on the recommended flights. | |
**Description**: Develop a personalized sleep schedule for the user that aligns with their travel itinerary, including flight timings, layovers, and destination time zone changes. | |
The sleep schedule should optimize rest and recovery, minimize jet lag, and ensure a smooth transition to the new time zone. | |
Consider the user's origin city, destination city, travel dates, and flight timings to create a tailored sleep plan that enhances their travel experience. | |
**Parameters**: | |
- Origin City: {origin_city} | |
- Destination City: {destination_city} | |
- Date of Departure: {date_of_departure} | |
- Date of Return: {date_of_return} | |
- Departure Flight: {departure_flight} | |
- Return Flight: {return_flight} | |
**Note**: {self.__tip_section()} | |
""" | |
), | |
agent=agent, | |
expected_output="A detailed sleep schedule for the user based on their travel itinerary." | |
) | |
def diet_plan(self, agent, date_of_departure, date_of_return, departure_flight, return_flight, food_preferences): | |
return Task( | |
description=dedent( | |
f""" | |
**Task**: Create a diet plan for the user based on their travel itinerary. | |
**Description**: Design a customized diet plan for the user that complements their travel itinerary, including meal timings, food choices, and hydration strategies. | |
The diet plan should support energy levels, promote digestion, and minimize the impact of jet lag on the user's health and well-being. | |
Consider the user's food preferences, travel dates, and meal timings to create a nutritionally balanced plan that enhances their travel experience. | |
**Parameters**: | |
- Food Preferences: {food_preferences} | |
- Date of Departure: {date_of_departure} | |
- Date of Return: {date_of_return} | |
- Departure Flight: {departure_flight} | |
- Return Flight: {return_flight} | |
**Note**: {self.__tip_section()} | |
""" | |
), | |
expected_output="A detailed diet plan for the user based on their travel itinerary.", | |
agent=agent, | |
) | |
def fitness_routine(self, agent, date_of_departure, date_of_return, departure_flight, return_flight, exercise_preferences): | |
return Task( | |
description=dedent( | |
f""" | |
**Task**: Recommend exercise routines for the user based on their travel itinerary. | |
**Description**: Provide tailored exercise recommendations for the user that align with their travel itinerary, including exercise types, timings, and intensity levels. | |
The exercise routines should support physical well-being, enhance energy levels, and mitigate the effects of jet lag on the user's body. | |
Consider the user's exercise preferences, travel dates, and daily schedule to create a workout plan that complements their travel experience. | |
**Parameters**: | |
- Exercise Preferences: {exercise_preferences} | |
- Date of Departure: {date_of_departure} | |
- Date of Return: {date_of_return} | |
- Departure Flight: {departure_flight} | |
- Return Flight: {return_flight} | |
**Note**: {self.__tip_section()} | |
""" | |
), | |
expected_output="Personalized exercise routines for the user based on their travel itinerary.", | |
agent=agent, | |
) | |
def plan_travel(self, agent, sleep_schedule, diet_plan, fitness_routine): | |
return Task( | |
description=dedent( | |
f""" | |
**Task**: Develop a detailed per-day plan of sleep, diet and exercise for 3 days before travel, during travel, and 3 days to avoid jet lag. | |
**Description**: Create a comprehensive travel plan inclduing flight details (Flight code and timings), sleep schedule, diet and exercise plan to minimize jet lag during and after travel. | |
You MUST consider the inputs from other agents and curate information together to minimizes the impact of jet lag. | |
The plan MUST include sleep timings, caffeine consumption, exposure to sunlight, food consumption, | |
and exercise routines based on the user's preferences. Format can be: | |
Flight Details: | |
- Departure Flight: [Flight Code] at [Time] | |
- Return Flight: [Flight Code] at [Time] | |
3 Days Before Travel (If user is travelling on 1st Jan, itenary should start from 29th Dec): | |
- Sleep Schedule: [Details] | |
- Diet Plan: [Details] | |
- Fitness Routine: [Details] | |
During Travel including day of journey: | |
- Sleep Schedule: [Details] | |
- Diet Plan: [Details] | |
- Fitness Routine: [Details] | |
After Travel: | |
- Sleep Schedule: [Details] | |
- Diet Plan: [Details] | |
- Fitness Routine: [Details] | |
**Note**: {self.__tip_section()} | |
""" | |
), | |
context=[sleep_schedule, diet_plan, fitness_routine], | |
expected_output="A detailed per-day plan of sleep, diet, and exercise for 3 days before travel, during travel, and 3 days after travel to avoid jet lag.", | |
agent=agent, | |
) | |