Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##Step 1 Setup and imports
- from crewai import Agent, Task, Crew
- from langchain_openai import OpenAI
- # Set up OpenAI API key
- OPENAI_API_KEY = "INSERT YOUR OPENAI API KEY HERE"
- # Initialize language model
- llm = OpenAI(temperature=0.7)
- ##Step 2 - Create agents
- # Create Travel Agent
- travel_agent = Agent(
- role='Travel Agent',
- goal='Create detailed travel itineraries with specific attractions and restaurants',
- backstory="""Experienced travel agent with extensive knowledge of
- global destinations and their attractions""",
- verbose=True,
- llm=llm
- )
- # Create Local Expert
- local_expert = Agent(
- role='Local Expert',
- goal='Provide insider knowledge with specific local recommendations',
- backstory="""Long-time resident with deep knowledge of local culture,
- cuisine, and hidden gems""",
- verbose=True,
- llm=llm
- )
- ## Step 3 - Create tasks
- # Task for creating initial itinerary
- create_itinerary_task = Task(
- description="""Create a detailed 3-day itinerary for Tokyo, Japan.
- For each day, include:
- - At least 3 specific attractions with their actual names and brief descriptions
- - 2 specific restaurant recommendations with cuisine types and signature dishes
- - Estimated times for each activity and meal
- - Brief travel instructions between locations
- Start your response with 'TOKYO ITINERARY:' """,
- agent=travel_agent,
- expected_output="A detailed 3-day Tokyo travel itinerary with specific locations and times."
- )
- # Task for enhancing itinerary with local insights
- enhance_itinerary_task = Task(
- description="""Review the Tokyo itinerary and enhance it with local insights.
- For each day:
- - Add 1-2 off-the-beaten-path attractions with specific names and why they're special
- - Suggest a local dining experience or food tour with a specific name and what makes it unique
- - Provide a tip for navigating Tokyo or experiencing Japanese culture
- Start your response with 'ENHANCED TOKYO ITINERARY:' followed by the complete, enhanced itinerary.""",
- agent=local_expert,
- expected_output="An enhanced Tokyo travel itinerary with specific local insights and experiences."
- )
- ## Step 4 - Assemble the Crew and Execute
- trip_planning_crew = Crew(
- agents=[travel_agent, local_expert],
- tasks=[create_itinerary_task, enhance_itinerary_task],
- verbose=2
- )
- print("\nPlanning a trip to Tokyo, Japan")
- result = trip_planning_crew.kickoff()
- print("\nFinal Tokyo Trip Itinerary:")
- print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement