Giter Site home page Giter Site logo

pushkarsule / flightbookingwithaiagents Goto Github PK

View Code? Open in Web Editor NEW

This project forked from henrischulte-ms/flightbookingwithaiagents

0.0 0.0 0.0 2.28 MB

Simple demo using Semantic Kernel and AutoGen to create an airline booking app powered by AI agents

License: MIT License

Python 77.35% CSS 10.47% HTML 12.18%

flightbookingwithaiagents's Introduction

๐Ÿ›ซ Flight Booking Demo with AutoGen and Semantic Kernel

Two pilots smiling
Image generated with DALLE-3 in Bing Image Creator

A small demo on combining AutoGen and Semantic Kernel to create a simple flight booking system that's powered by AI agents. The application allows users to provide booking instructions once, e.g., "Book the cheapest flight from Tokyo to Toronto", and then lets AI agents determine how to complete the task without any additional user input.

The demo includes two agents: An LLM-powered assistant and a worker agent that is capable of executing Semantic Kernel plugins (formerly known as skills). In addition to the built-in TimeSkill that gives the agent access to time and date operations, the agent also has access to a custom FlightsPlugin that enables looking up flights between two cities and to issue a (simulated) booking request.

To make the agents' thought process transparent, the app visualizes their back-and-forth in a chat format. The interactions of the agents depend on the flights data and user instructions. An example:

Role Message
๐Ÿ‘ค User Book the cheapest flight from Tokyo to Toronto
๐Ÿค– Assistant Making a call to GetFlights function with input "Tokyo, Toronto"
๐Ÿ–ฅ๏ธ GetFlights List of flights from Tokyo to Toronto, incl. details like time and price
๐Ÿค– Assistant Making a call to BookFlights function with the flight ID of the cheapest flight
๐Ÿ–ฅ๏ธ BookFlight The flight could not be booked. There are no free seats available.
๐Ÿค– Assistant I regret to inform you that the cheapest flight from Tokyo to Toronto is currently fully booked. Let's try to book the next available option for you.
Making a call to BookFlights function with the flight ID of the next cheapest flight
๐Ÿ–ฅ๏ธ BookFlight Flight successfully booked.
๐Ÿค– Assistant Great news! I've successfully booked your flight from Tokyo to Toronto. This is your flight detail: [...]

This project was inspired by John Maeda's devblog AutoGen Agents Meet Semantic Kernel.

Running the app locally

This app utilizes Azure OpenAI for Large Language Models and Azure CosmosDB for data storage. You can run the application itself locally by following the steps below.

Setting up your environment

  1. Clone this repo to your machine.
  2. Create a Python virtual environment and activate it, e.g. by running python3 -m venv .venv and source .venv/bin/activate.
  3. Install the libraries listed in requirements.txt by running pip install -r app/requirements.txt.
  4. Rename the .env.example file to .env. You will populate it in the next section.

Setting up your Azure resources

  1. Create an Azure OpenAI resource and deploy a gpt-35-turbo or gpt-4 model.
  2. Add the deployment name, resource endpoint, and key to the .env file.
  3. Create an Azure CosmosDB resource, specifically, "Azure Cosmos DB for NoSQL". Within, create a database AirlineBooking and a container Flights.
  4. Add the read-write connection string for your CosmosDB resource to the .env file.
  5. To populate the database, run populate_cosmos.py a few (e.g., 10) times (python3 setup/populate_cosmos.py). You might have to install pandas if it's not present in your virtual environment (pip install pandas). Every time you run it, the script adds three new flights to the database.

Running the application

  1. In your terminal, switch to the app directory.
  2. Run flask run to start the app.
  3. Click the link in your terminal or navigate to http://127.0.0.1:5000 in your browser to view the application.
  4. Enter your instructions and click Send. The agents will react to your instructions and the final result is displayed. To see intermediate steps, click Show intermediate steps. You can try a new instruction by clicking Start over in the bottom of the page.

Example walkthrough

  1. Once the application is up and running, enter a promp such as Book the cheapest flight from Brussels to Vienna into the input box. Hit send.
  2. It might take some seconds for the app to respond. You can watch the progress in your terminal to see what is happening behind the scenes.
  3. You should receive an output in your webbrowser saying that a flight has been successfully booked.
  4. You can have a look at the intermediate steps to see how the AI agents came to the conclusion to finally have a flight booked for you.

Please note: For the demo to run successfully, you'll need to verify that CosmosDB contains direct flights between the requested cities.

Screenshots

demo start demo final

flightbookingwithaiagents's People

Contributors

henrischulte-ms avatar mslifn avatar jetzlstorfer 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.