Skip to content

nirbar1985/ai-travel-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✈️🧳 AI Travel Agent - Powered by LangGraph: A Practical Use Case 🌍

Welcome to the AI Travel Agent repository! This project demonstrates how to leverage LangGraph for building a smart travel assistant that uses multiple language models (LLMs) to handle tasks such as finding flights, booking hotels, and sending personalized emails. The agent is designed to interact with users, invoke necessary tools, and provide a seamless travel planning experience.

Features

  • Stateful Interactions: The agent remembers user interactions and continues from where it left off, ensuring a smooth user experience.
  • Human-in-the-Loop: Users have control over critical actions, like reviewing travel plans before emails are sent.
  • Dynamic LLM Usage: The agent intelligently switches between different LLMs for various tasks, like tool invocation and email generation.
  • Email Automation: Automatically generates and sends detailed travel plans to users via email.

Getting Started

Clone the repository, set up the virtual environment, and install the required packages

  1. git clone git@github.com:nirbar1985/ai-travel-agent.git

  2. ( In case you have python version 3.11.9 installed in pyenv)

    pyenv local 3.11.9
  3. Install dependencies

    poetry install --sync
  4. Enter virtual env by:

    poetry shell

Store Your API Keys

  1. Create a .env file in the root directory of the project.
  2. Add your API keys and environment variables to the .env file:
    OPENAI_API_KEY=your_openai_api_key
    SERPAPI_API_KEY=your_serpapi_api_key
    SENDGRID_API_KEY=your_sendgrid_api_key
    
    # Observability variables
    LANGCHAIN_API_KEY=your_langchain_api_key
    LANGCHAIN_TRACING_V2=true
    LANGCHAIN_PROJECT=ai_travel_agent
    

Make sure to replace the placeholders (your_openai_api_key, your_serpapi_api_key, your_langchain_api_key, your_sendgrid_api_key) with your actual keys. This version includes the necessary environment variables for OpenAI, SERPAPI, LangChain, and SendGrid and the LANGCHAIN_TRACING_V2 and LANGCHAIN_PROJECT configurations.

How to Run the Chatbot

To start the chatbot, run the following command:

streamlit run app.py

Using the Chatbot

Once launched, simply enter your travel request. For example:

I want to travel to Amsterdam from Madrid from October 1st to 7th. Find me flights and 4-star hotels.

photo1

The chatbot will generate results that include logos and links for easy navigation.

Note: The data is fetched via Google Flights and Google Hotels APIs. There’s no affiliation or promotion of any particular brand.

Example Outputs

  • Flight and hotel options with relevant logos and links for easy reference:

photo2

photo3

Email Integration

The email integration is implemented using the human-in-the-loop feature, allowing you to stop the agent execution and return control back to the user, providing flexibility in managing the travel data before sending it via email.

photo4

  • Travel data formatted in HTML, delivered straight to your inbox: photo5 photo6

Learn More

For a detailed explanation of the underlying technology, check out the full article on Medium: Building Production-Ready AI Agents with LangGraph: A Real-Life Use Case)

License

Distributed under the MIT License. See LICENSE.txt for more information.

About

AI Travel Agent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages