GithubHelp home page GithubHelp logo

multiagent-crewai's Introduction

MultiAgent-CrewAI: Automated Vacation Planner Using Multiple AI Agents

This project demonstrates how to create an automated vacation planner using AI agents and the Crew AI framework. The planner autonomously handles various aspects of vacation planning, such as finding accommodation, planning daily itineraries, and managing the budget.

Table of Contents

  1. Introduction
  2. Project Structure
  3. Setup Instructions
  4. Agents Definition
  5. Tasks Definition
  6. Running the Project
  7. Final Output

Introduction

This project leverages the Crew AI framework to create a multi-agent system that automates the process of planning a vacation. By defining specialized agents and their respective tasks, the system can efficiently find accommodation, plan daily activities, and manage the budget for a vacation.

Project Structure

  • travel_agent.py: Main script that defines agents, tasks, and executes the vacation planning process.
  • utils.py: Utility functions for fetching API keys.
  • requirements.txt: List of required Python packages.

Additional Multi-Agent Examples for You to Explore:

  • python_writer.py: Describe a task you want implemented in Python and the crew will output the Python code.
  • stock_analysis.py: Describe a stock you want analyzed in the market and the crew will give feedback on it.
  • resume_builder.py: Give the crew your current resume in markdown format along with a job posting link and your github. It will tailor the resume to the job you are applying for. fake_resume.md is included in the repo for you to play around with the code with this resume.

Setup Instructions

Prerequisites

  • Python 3.7+
  • OpenAI API key
  • Serper API key

Step-by-Step Setup

  1. Clone the Repository

    git clone https://github.com/techindicium/MultiAgent-CrewAI.git
    cd MultiAgent-CrewAI
  2. Install Required Packages

    pip install -r requirements.txt
  3. Set Up API Keys

    • Create a file named .env in the root directory of the project and add your API keys:
      OPENAI_API_KEY=your_openai_api_key
      SERPER_API_KEY=your_serper_api_key

Agents Definition

Agents are autonomous units that perform specific roles within the vacation planning process. We define three agents in this project:

Venue Coordinator

  • Role: Identify suitable accommodation options.
  • Tools: SerperDevTool, ScrapeWebsiteTool
  • Goal: Find hotels, rental homes, or vacation rentals that meet specified criteria.
rental_coordinator = Agent(
    role="Hotel/Rental Coordinator",
    goal="Identify an appropriate hotel, rental home, or vacation rental.",
    tools=[search_tool, scrape_tool],
    verbose=True,
    backstory=(
        "With a keen sense of space and understanding of vacation logistics, "
        "you excel at finding and securing the perfect vacation rental that fits "
        "the vacation's location, start and end dates, group size, and budget constraints."
    )
)

Itinerary Planner

  • Role: Create a detailed itinerary including daily excursions and activities.
  • Tools: SerperDevTool, ScrapeWebsiteTool
  • Goal: Plan activities considering the traveler's interests, budget, and logistics.
itinerary_planner = Agent(
    role="Itinerary Planner",
    goal="Create a proposed itinerary including daily excursions and activities.",
    tools=[search_tool, scrape_tool],
    verbose=True,
    backstory=(
        "With a passion for adventure and local culture, you specialize in planning engaging "
        "and budget-friendly itineraries, taking into account the traveler's interests, budget, "
        "and logistics like transportation needs."
    )
)

Budgeting Agent

  • Role: Manage the overall budget for the trip.
  • Tools: SerperDevTool
  • Goal: Ensure all aspects of the vacation stay within the allocated budget.
budgeting_agent = Agent(
    role="Budgeting Agent",
    goal="Manage the overall budget for the trip, considering the cost of accommodation and daily activities.",
    tools=[search_tool],
    verbose=True,
    backstory=(
        "With a knack for financial planning, you ensure the vacation remains within budget while maximizing value and enjoyment."
    )
)

Tasks Definition

Tasks define what each agent needs to accomplish. Properly structured tasks are crucial for guiding agents to perform their roles effectively.

Venue Coordinator Task

hotel_task = Task(
    description="Find a hotel or rental in {vacation_city} "
                "that meets criteria for {vacation_details}, {budget}, {group_size}, {start_date} and {end_date}.",
    expected_output="Details of suitable rental options, including name, address, capacity, price per night, available dates, description, and amenities.",
    human_input=True,
    output_json=RentalDetails,
    output_file="venue_details.json",
    agent=rental_coordinator
)

Itinerary Planner Task

itinerary_task = Task(
    description="Plan a full itinerary for the trip in {vacation_city}, considering {vacation_details}, {budget}, and {group_size}. Include daily excursions and local activities, specifying if a rental car is needed.",
    expected_output="A detailed itinerary for each day of the trip, including activities, locations, estimated costs, and rental car needs.",
    human_input=True,
    output_json=FullItinerary,
    output_file="itinerary_details.json",
    agent=itinerary_planner
)

Budgeting Agent Task

budgeting_task = Task(
    description="Ensure the total cost of the trip, including accommodation and daily activities, stays within the allocated budget of {budget}.",
    expected_output="Adjusted itinerary with budget considerations, including the cost of accommodation and daily activities.",
    human_input=True,
    output_json=FullItinerary,
    output_file="final_itinerary.json",
    agent=budgeting_agent
)

Running the Project

To run the vacation planner, follow these steps:

  1. Initialize the Crew Define the crew with the agents and tasks.

    vacation_planning_crew = Crew(
        agents=[rental_coordinator, itinerary_planner, budgeting_agent],
        tasks=[hotel_task, itinerary_task, budgeting_task],
        manager_llm=ChatOpenAI(model="gpt-3.5-turbo", temperature=0.7),
        process=Process.hierarchical,
        verbose=True
    )
  2. Kickoff the Process Provide the necessary input data and start the execution.

    vacation_details = {
        'vacation_city': "Honolulu",
        'vacation_details': "A vacation for an adventurous family of 7 who want to explore the island, see the nature, and experience some good Hawaiian food and culture",
        'start_date': "2024-06-15",
        'end_date': "2024-06-22",
        'group_size': 7,
        'budget': 10000,
    }
    
    result = vacation_planning_crew.kickoff(inputs=vacation_details)
  3. Load and Print the Final Itinerary After the tasks are completed, load the results from the JSON file.

    with open('final_itinerary.json') as f:
        final_itinerary_data = json.load(f)
    
    pprint(final_itinerary_data)

Final Output

The final output will be a detailed itinerary for the vacation, including:

  • Accommodation options
  • Daily activities and excursions
  • Budget management details

This output is saved in final_itinerary.json and can be printed for review.

By following these steps, you can recreate the automated vacation planner and understand how AI agents interact to achieve the overall goal. This approach demonstrates the power of AI-driven automation in simplifying and streamlining complex processes.

multiagent-crewai's People

Contributors

ttboogie avatar

Stargazers

Rakesh The Debur avatar

Watchers

Felipe Souto Campelo avatar Daniel Avancini avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.