- This code is forked from the trip planning notebook from AG2.
- By Mark
In this project, we're building a trip planning swarm which has an objective to create an itinerary together with a customer. The end result will be an itinerary that has route times and distances calculated between activities.
The following diagram outlines the key components of the Swarm, with highlights being:
- FalkorDB agent using a GraphRAG database of restaurants and attractions
- Structured Output agent that will enforce a strict format for the accepted itinerary
- Routing agent that utilises the Google Maps API to calculate distances between activites
- Swarm orchestration utilising context variables
This project demonstrates the following AG2 features:
TAGS: trip planning, swarm, graphrag, structured output, itinerary planning, travel automation, routing agent, falkordb, google maps integration
-
Clone and navigate to the folder:
git clone https://github.com/ag2ai/build-with-ag2.git cd build-with-ag2/game_design_agent_team
-
Install the required dependencies:
pip install -r requirements.txt
The dependency is ag2 with graphrag option.
-
Set up a FalkorDB graph database. Please refer to https://docs.falkordb.com/. After the database is running, please adjust FalkorDB host and port accordingly (line 74-75 in
main.py
). A quick way is to set up docker and run this command:docker run -p 6379:6379 -p 3000:3000 -it --rm falkordb/falkordb:latest
Note: You need to have a FalkorDB graph database running. If you are running one in a Docker container, please ensure your Docker network is setup to allow access to it.
To use Google's API to calculate travel times, you will need to have enabled the Directions API
in your Google Maps Platform. You can get an API key and free quota, see here and here for more details.
Once you have your API key, set your environment variable GOOGLE_MAP_API_KEY
to the key.
Please modify the config_list
in the main.py
file (line 35). Read more about configurations here. This configuration will be used to set up ag2 agents.
By default, FalkorDB uses OpenAI LLMs and that requires an OpenAI key in your environment variable OPENAI_API_KEY
. We will extract the key from the configuration you set (line 49). If you are not using OpenAI in config_list
, you may comment out the line and read from your environment variable directly.
python main.py
You can now interact with the system through the command line to plan a trip to Rome! You can also modify the initial message to plan a trip to another city.
Note: after first run of the code, the db will be initialized and you can switch to connect_db
in line 82 and 85 in main.py
for faster rerun.
For more information or any questions, please refer to the documentation or reach out to us!
- AG2 Documentation: https://docs.ag2.ai/docs/Home
- AG2 GitHub: https://github.com/ag2ai/ag2
- Discord: https://discord.gg/pAbnFJrkgZ
This project is licensed under the Apache License 2.0. See the LICENSE for details.