Note: This project simulates an industry-standard scenario where I am assuming the role of a developer at XYZ Company. The client required a system to provide users with accurate, detailed, and instant information about travel destinations. This system was to be embedded into their platform for seamless user experience, ensuring that users could fetch trip details in one go with pinpoint accuracy.
High-Level Note: Some related topics, such as AI agents, their pipelines, different types of agents, and RAG (Retrieval-Augmented Generation) systems in general, have already been discussed. You can find these details in the docs
folder for further exploration.
At XYZ Company, we were tasked with creating a robust system for a client that could fetch and deliver comprehensive trip details in a single query. The aim was to make the users' lives easier by integrating a trip planner system into their platform, enabling seamless access to detailed destination information in one go.
To achieve this, Taskflow AI was chosen due to its:
- Multi-AI agent support: Making it highly adaptable for complex workflows.
- Capabilities for modular design: Ensuring scalability and maintainability for future upgrades.
As a developer, my manager entrusted me to deliver this project with high-quality results within a strict time frame. My responsibilities included:
- Designing a system that could provide users with accurate and detailed destination information in one query.
- Ensuring the system had a modular architecture, allowing easy future upgrades and scalability.
- Managing cost efficiency while maintaining performance and reliability.
I chose Taskflow AI because of its support for multi-AI agent integration and its capability to deliver modular and scalable solutions tailored to client needs.
-
Deliver a System to Meet Client Needs
- Create a system to provide accurate and instant destination insights, fulfilling the user's requirements seamlessly.
-
Build a Modular Architecture
- Design the system to support scalability and future upgrades.
-
Testing and Quality Assurance
- Ensure the system's reliability and accuracy through rigorous testing.
-
Cost-Effective Measures
- Optimize API and model-related costs without compromising performance.
The project followed a structured approach to ensure efficient execution and high-quality results.
-
Framework Selection
- Chose Taskflow AI for its multi-AI agent support and capabilities in modular design.
-
Model Selection
- Tested multiple models, including:
- OpenAI Models:
- The GPT-3.5 Turbo model was ultimately chosen due to its:
- Tool-Calling Excellence: It demonstrated the best ability to call tools and manage multi-agent tasks seamlessly, ensuring outstanding integration with the system.
- Token Management: The model's reasoning capabilities enabled it to self-understand context and optimize token usage, producing exceptional results.
- Report Generation: Its power to combine, process, and generate final reports effectively, as showcased in this project.
- The GPT-3.5 Turbo model was ultimately chosen due to its:
- LLaMA Models: Failed to handle larger token inputs effectively and lacked robust reasoning capabilities, resulting in subpar outcomes.
- Google Models: While capable of handling large contexts, they failed in reasoning and memory performance, making them unsuitable for this use case.
- OpenAI's o1 Series Models: Offered great performance but were prohibitively expensive for this project.
- OpenAI Models:
- Additionally, tested with Groq inference engine, which also failed to meet the project's performance indicators.
-
System Design and Development
- Built a modular architecture using Taskflow AI, ensuring the system could adapt to future needs and upgrades.
-
Cost Optimization
- Prioritized minimizing API costs by choosing the GPT-3.5 Turbo model and optimizing system performance.
-
Testing and Delivery
- Conducted rigorous testing to validate accuracy and reliability.
- Delivered the project on time, exceeding quality expectations.
The project faced several challenges, including:
- Model API Costs: Managing the high costs of API calls while ensuring performance.
- Token Limitations: Handling large queries within the token limits of various models.
- Memory Issues: Ensuring memory efficiency for better performance.
-
Model API Costs:
- Evaluated multiple models and frameworks, but GPT-3.5 Turbo was chosen for its cost-effectiveness and outstanding performance.
-
Token Limitations:
- OpenAI's GPT-3.5 Turbo effectively managed token constraints by leveraging its powerful reasoning capabilities, optimizing token usage, and maintaining context to generate accurate results.
-
Memory Challenges:
- Compared with other models like LLaMA and Google's offerings, GPT-3.5 Turbo proved superior in handling memory-intensive tasks and maintaining consistent performance.
Note: This system is now live, providing users with a seamless and efficient way to fetch trip details in one go. It showcases the potential of modular AI architectures in real-world applications.
- In this example, I am loading the GPT-3.5 Turbo model from taskflowai.OpenaiModels.
- This model is efficient, cost-effective, and performs exceptionally well for most tasks.
- Make sure to load the OpenAI API key properly.
- It is recommended to store the API key securely using a
.env
file or a similar approach.
Web Research Agent:
- Here, I define the Web Research Agent, which is responsible for conducting web-based research and retrieving relevant information.
- I assign the role of "Web Research Agent" to the agent, ensuring it focuses on researching destinations and finding related images.
- The goal is set to perform thorough and comprehensive research with a visual focus.
- I specify attributes like diligence, thoroughness, and visual-focus to guide the agent's behavior during tasks.
- I load the OpenAI model using
LoadModel.load_openai_model()
to empower the agent with natural language processing capabilities. - I include tools like:
- SerperSearch: For detailed web searches.
- WikiArticles: To fetch related articles for context.
- WikiImages: To search and retrieve relevant images.
Travel Agent:
- Here, I define the Travel Agent, which is designed to assist travelers with their queries, focusing on searching for flights and retrieving weather data.
- The role assigned to the agent is "Travel Agent," ensuring its primary function is to help travelers.
- The goal is set to assist travelers by providing relevant information such as flight details and weather conditions.
- I specify attributes like friendliness, hard work, and attention to detail to ensure the agent delivers thorough and useful responses.
- I load the OpenAI model using
LoadModel.load_openai_model()
to provide natural language processing capabilities. - I include tools like:
- SearchFlights: A tool for searching and retrieving flight information using the Amadeus API.
- GetWeatherData: A tool for fetching real-time weather data from weather.com API.
Reporter Agent:
- Here, I define the Travel Report Agent, which aggregates data from various agents like the Web Search Agent and Travel Agent to generate comprehensive and summarized travel reports.
- The role assigned to the agent is "Travel Report Agent," ensuring its focus on collecting and synthesizing travel-related information.
- The goal is to write detailed, visual-oriented, and comprehensive travel reports based on inputs from other agents, covering destination details, dates, weather reports, flight information, and events at the location.
- I specify attributes like friendliness, hard work, visual focus, and attention to detail to ensure the agent delivers well-structured, insightful, and informative reports.
- I load the OpenAI model using
LoadModel.load_openai_model()
to provide natural language processing and text generation capabilities. - The agent relies on tools and data from other agents, such as:
- Web Search Agent: Provides destination details and event-related information.
- Travel Agent: Supplies weather reports and flight information.
Wiki Image Search Tool:
- Here, I define the WikiImages tool, which is responsible for searching images from Wikipedia using TaskflowAI's WikipediaTools.
- The goal of the tool is to fetch relevant images based on specific queries or topics.
- It leverages WikipediaTools from TaskflowAI to access and retrieve image data from Wikipedia.
Wiki Article Search Tool:
- Here, I define the WikiArticles tool, which is responsible for fetching articles from Wikipedia using TaskflowAI's WikipediaTools.
- The goal of the tool is to retrieve relevant articles based on specific queries or topics.
- It utilizes WikipediaTools from TaskflowAI to access and fetch article data from Wikipedia.
Serper Search Tool:
- Here, I define the SerperSearch tool, which is responsible for performing web searches using TaskflowAI's WebTools.
- The goal of the tool is to retrieve search results from the web based on specific queries or topics.
- It leverages WebTools from TaskflowAI to perform search operations using the SerperSearch API.
Weather Fetching Tool:
- Here, I define the GetWeatherData tool, which is responsible for fetching weather data using TaskflowAI's WebTools and the Weather.com API.
- The goal of the tool is to retrieve weather-related information based on location or other relevant queries.
- It utilizes WebTools from TaskflowAI to interact with the Weather.com API and fetch weather data.
Search Fligts Tool:
- Here, I define the SearchFlights tool, which is responsible for searching flights using TaskflowAI's AmadeusTools and the Amadeus API.
- The goal of the tool is to retrieve flight information based on specific queries such as origin, destination, dates, and other relevant parameters.
- It leverages AmadeusTools from TaskflowAI to interact with the Amadeus API for flight searches.
Ok, so now let's talk the app.py
where everything is bought together (see how tasks are defined, to later engage with UI)
Research Destination Task (streamlit UI):
- In this code snippet, I import the necessary modules from TaskflowAI, including Task, set_verbosity, and Web Research Agent from
src.agentic.agents.web_research_agent
. - The
research_destination
function takes a destination and interests as input to gather detailed information about the destination. - The function utilizes the WebResearchAgent, which combines tools like WikipediaTools (for article and image searches) and SerperSearch (for web searches) to extract relevant data.
- The
Task.create
method invokes the WebResearchAgent to fetch high-quality images, attraction details, and relevant activities based on user interests. - The research output is formatted in clean markdown, ensuring well-structured and informative reports.
Research Events Task (streamlit UI):
- The
research_events
function utilizes the WebResearchAgent imported fromsrc.agentic.agents.web_research_agent
. - The WebResearchAgent employs tools like WikipediaTools (for image searches) and SerperSearch (for web search) to collect event-related data.
- The function generates a detailed report about events in a specified destination during given dates, based on provided interests.
- The instruction includes:
- Event name, date, time, venue/location, ticket information, and a short description.
- Images formatted as
![Event Name](https://full-image-url)
or![Description](https://full-image-url)
. - Ensuring URLs are complete and starting with
http://
orhttps://
. - Formatting the entire response in clean markdown with images placed naturally within the content.
Research Weather (streamlit UI):
- The
research_weather
function uses the TravelAgent imported fromsrc.agentic.agents.travel_agent
. - The TravelAgent employs tools like GetWeatherData, which fetches weather information using the Weather.com API.
- The function generates a weather report for a specific destination and dates.
- The instruction includes:
- Temperature ranges.
- Precipitation chances.
- General weather patterns.
- Recommendations for clothing and gear.
Search Flights Task (streamlit UI):
- The
search_flights
function uses the TravelAgent, imported fromsrc.agentic.agents.travel_agent
. - The TravelAgent utilizes tools like SearchFlights, which leverages the Amadeus API to search for flight options.
- The function identifies flights from a current location to a destination on specific dates.
- The instruction specifies:
- Finding the top 3 affordable and convenient flight options.
- Providing concise bullet-point details for each option.
Write Travel Report Task (streamlit UI):
- The
write_travel_report
function uses the ReporterAgent, imported fromsrc.agentic.agents.reporter_agent
. - The ReporterAgent combines multiple reports (destination, events, weather, and flight reports) into a single comprehensive travel report.
- The instruction for creating the travel report includes:
- Retaining all images from the destination and events reports.
- Organizing information with a clear and logical structure.
- Preserving all markdown formatting.
- Ensuring images are properly displayed with captions.
- Incorporating all essential information from each individual report section.
- end to
main pipeline
See the deployment diagram to gain a better understanding of the infrastructure and components involved in the deployment process.
After completing the main pipeline, it's now time to deploy it on the cloud. The steps below outline the process for deploying the Dockerized application to AWS using GitHub Actions Self Hosted Runner.
Prerequisites:
- Access to AWS.
- Necessary API keys and secrets stored securely as GitHub secrets.
- SSH access to the EC2 instance with an EC2 key pair's PGP key added to GitHub secrets.
Steps to Deploy:
-
Checkout the Code
Pull the latest code from themain
branch to ensure the most up-to-date version of the application is deployed. -
Verify Docker Setup
Confirm that Docker is installed and properly configured on the self-hosted runner by checking permissions and verifying the Docker daemon. -
Build the Docker Image
Create a Docker image for the Streamlit application using the necessary build arguments like API keys. -
Authenticate to AWS
Log in to AWS using the provided credentials to access the Elastic Container Registry (ECR). -
Push Docker Image to AWS ECR
Tag the Docker image and push it to AWS Elastic Container Registry for deployment. -
Deploy to EC2 Instance
- Pull the latest Docker image from AWS ECR onto the EC2 instance.
- Stop and remove any running instance of the application.
- Run the updated Docker container with the necessary environment variables and expose it on the desired port.
Ensure you store all the API keys (e.g., OPENAI_API_KEY
, WEATHER_API_KEY
, SERPER_API_KEY
, AMADEUS_API_KEY
, AMADEUS_API_SECRET
) securely in GitHub secrets.
Ensure you add your EC2 key pair's PGP key to GitHub secrets to allow SSH access to the EC2 instance.
If you want to see the detailed YAML configuration file for this workflow, navigate to .github/workflows/deploy.yml
.
If you need Docker and GitHub Self-Hosted Runner commands, I have provided them in the scripts.sh
file. However, note that GitHub Self-Hosted Runner commands are different for every account. Go to -> Repo Settings -> Actions -> Runners -> New Self-Hosted Runner.
Dear Developers,
To create a similar project, set up your environment using Python 3.10 or above with Conda:
conda create -p your_env_name python=3.10
Activate the env:
conda activate your_env_path
Then, install the required packages:
pip install -r requirements.txt
I recommend using TaskflowAI here because of its modularity design, which is crucial for building scalable AI/ML applications. When productionizing AI or ML apps, having a modular design from the beginning is essential. So, I recommend following the main pipeline and deployment steps as outlined.
You can fork this repo as TaskflowAI is simple and easy to understand. Here is the documentation link: TaskflowAI Documentation. Feel free to explore more or contribute. It provides tools to work with multi-AI agents and multi-agent system design easily, and there are also other frameworks such as Langchain's langgraph, crewai etc, you can use those too.
Happy coding and building multi-ai-agent-system! ππ
βββ .github/workflows/
β βββ deploy.yml
βββ deployment/
β βββ app.py
βββ docs/
β βββ Agentic RAG Pipeline.md
β βββ Types of Agentic RAG.md
βββ flowcharts/
β βββ project_pipeline.jpg
βββ log/
β βββ timestamp(log)
βββ notebooks/
β βββ TripPlanner_Multi_AI_Agent_Experimental.ipynb
βββ src/agentic/
β βββ agents/
β β βββ reporter_agent.py
β β βββ travel_agent.py
β β βββ web_research_agent.py
β βββ exception/
β β βββ __init__.py
β βββ logger/
β β βββ __init__.py
β βββ tools/
β β βββ get_weather_data.py
β β βββ search_articles.py
β β βββ search_flights.py
β β βββ search_images.py
β β βββ serper_search.py
β βββ utils/
β βββ __init__.py
β βββ main_utils.py
βββ .gitignore
βββ demo.py
βββ LICENSE
βββ README.md
βββ requirements.txt
βββ scripts.sh
βββ setup.py
βββ template.py
This project is licensed under the MIT License.
You are free to use, modify, and share this project, as long as proper credit is given to the original contributors.
For more details, check the LICENSE file. ποΈ