Spaces:
Sleeping
Sleeping
| from crewai import Agent | |
| from textwrap import dedent | |
| from langchain.llms import OpenAI, Ollama | |
| from langchain_openai import ChatOpenAI | |
| #from tools.search_tools import SearchTools | |
| from crewai_tools import SerperDevTool | |
| """ | |
| Creating Agents Cheat Sheet: | |
| - Think like a boss. Work backwards from the goal and think which employee | |
| you need to hire to get the job done. | |
| - Define the Captain of the crew who orient the other agents towards the goal. | |
| - Define which experts the captain needs to communicate with and delegate tasks to. | |
| Build a top down structure of the crew. | |
| Goal: | |
| - Create a plan to avoid jet lag happens during and after travel with detailed per-day plans, | |
| including sleep timings, caffeine consumption, exposure to sunlight, food consumption, | |
| when to do exercise based on user's interest (Gym, Running or does not exercise). | |
| Plan will be done for 3 days before travel, during travel, and 3 days after travel based | |
| on itenary shared by user | |
| Captain/Manager/Boss: | |
| - Expert Doctor who can be general physician or sleep specialist | |
| Employees/Experts to hire: | |
| - Flight Agent | |
| - Sleep Specialist | |
| - Dietician | |
| - Fitness Trainer | |
| Notes: | |
| - Agents should be results driven and have a clear goal in mind | |
| - Role is their job title | |
| - Goals should actionable | |
| - Backstory should be their resume | |
| """ | |
| class TravelAgents: | |
| def __init__(self): | |
| self.OpenAIGPT35 = ChatOpenAI(model="gpt-3.5-turbo", temperature=0.7) | |
| self.OpenAIGPT4 = ChatOpenAI(model="gpt-4", temperature=0.7) | |
| self.OpenAIGPT4oMini = ChatOpenAI(model="gpt-4o-mini", temperature=0.7) | |
| self.Ollama = Ollama(model="openhermes") | |
| def sleep_specialist(self): | |
| return Agent( | |
| role="Sleep Specialist", | |
| backstory=dedent(f"""Expert in sleep medicine with a focus on diagnosing and treating sleep disorders such as insomnia, sleep apnea, and circadian rhythm disorders. I have extensive experience in helping patients improve their sleep quality and overcome jet lag through evidence-based interventions and personalized treatment plans. I am dedicated to educating individuals about the importance of sleep and providing them with the tools and strategies they need to optimize their sleep health."""), | |
| goal=dedent(f"""Recommend sleep timings and exposure to sunlight to avoid jet lag"""), | |
| tools=[SerperDevTool()], | |
| verbose=False, | |
| llm=self.OpenAIGPT4oMini, | |
| ) | |
| def dietician(self): | |
| return Agent( | |
| role="Diet expert", | |
| backstory=dedent(f"""Expert in nutrition and dietetics with a focus on creating personalized diet plans to help individuals achieve their health and wellness goals. I have a background in clinical nutrition and have worked with clients to improve their overall health, manage chronic conditions, and optimize their performance through nutrition. I am passionate about helping people make informed food choices and develop healthy eating habits that support their well-being."""), | |
| goal=dedent(f"""Recommend the best diet to avoid jet lag including caffiene consumption and also the food which can help in reducing the jet lag and keep user healthy"""), | |
| tools=[SerperDevTool()], | |
| verbose=False, | |
| llm=self.OpenAIGPT4oMini, | |
| ) | |
| def fitness_trainer(self): | |
| return Agent( | |
| role="Expert fitness trainer", | |
| backstory=dedent(f"""Expert in fitness training with a focus on creating personalized exercise plans to help individuals achieve their fitness goals and improve their overall health and well-being. I have experience working with clients of all fitness levels and backgrounds, from beginners to athletes, and have helped them develop effective workout routines that are safe, challenging, and enjoyable. I am passionate about promoting physical activity as a key component of a healthy lifestyle and empowering individuals to take control of their fitness journey."""), | |
| goal=dedent(f"""Recommend the best exercise plan to avoid jet lag including the type of exercise (Gym, Running, or other) and the best time to exercise before, during, and after travel"""), | |
| tools=[SerperDevTool()], | |
| verbose=True, | |
| llm=self.OpenAIGPT4oMini, | |
| ) | |
| def expert_itenary_planner(self): | |
| return Agent( | |
| role="Expert Itenary Planner", | |
| backstory=dedent(f"""I am an itenary planner with expertise in creating personalized travel plans to help individuals avoid jet lag and optimize their travel experience. I have experience working with clients to develop detailed itenaries that include sleep timings, caffeine consumption, exposure to sunlight, food consumption, and exercise routines based on their preferences and travel schedule. I am dedicated to providing individuals with the tools and strategies they need to stay healthy and well-rested during and after travel."""), | |
| goal=dedent(f"""Summarize the findings from the previous tasks and provide clear recommendations for the user to follow to avoid jet lag. Create a day wise itenary for 3 days before travel, during travel, and 3 days after travel"""), | |
| verbose=True, | |
| llm=self.OpenAIGPT4oMini, | |
| ) | |