How to
Your Guide to Building an AI Travel Consultant
Aug 1, 2023
·
Feb 4, 2024
What is Dify.AI?
Dify.AI is an open-source and user-friendly LLMOps platform that assists developers in building AI applications more simply and swiftly. Dify combines the concepts of Backend as a Service and LLMOps, offering features like visual Prompt orchestration, operation, dataset management, a built-in RAG engine, and AI Agent functionality. With Dify, you can create an AI application in minutes or quickly integrate LLM into your existing applications for ongoing operation and improvement, creating truly valuable AI applications. Dify allows you to deploy capabilities similar to Assistants API and GPTs based on any model (currently supporting all popular LLMs on the market).
After Dify released the latest Agent Assistant mode, many are curious about what kind of products Dify can deliver. This article will showcase one scenario - creating a travel itinerary based on the user's needs.
I will guide you step-by-step on how to use Dify's latest Agent capabilities to build a travel consultant, answering a series of questions:
What features does Dify have?
How to apply Dify in travel and itinerary planning?
How to write perfect prompts?
How to publish your application on Dify and integrate it into your workflow?
For those who like to plan ahead, planning a trip to an unfamiliar place is still challenging due to the varying quality of information on the Internet. With the rise of technology and AI, travel advisors can now be replaced by AI, greatly enhancing the travel experience. In this guide, we will explore how to quickly create a travel advisor Agent to craft itineraries, book accommodations, and find great restaurants.
How good is the travel planning assistant?
Let's start with a talent showcase of our AI Agent: we tried to generate a 3-day travel plan to New York.
Users can input their destination, number of travel days, or budget. After completion, our Agent can provide information on local conditions and accommodations via Wikipedia and Google searches, as well as offer local dining and lodging features, prices, and reviews by browsing web pages.
Steps to create a Travel Consultant
How to build an Agent Assistant?
Create an application.
Write the prompts.
Configure tools for the agent.
What's next? How to deploy and use it in production?
Prerequisites
Prerequisites
Register or deploy Dify.AI
Dify is an open-source product. You can find it on GitHub and then deploy it locally or on your company's intranet. It also offers a cloud-based SaaS version, accessible at Dify.AI for use upon registration.
Apply for the API key from model providers like OpenAI
AI model message calls consume tokens. Dify provides new registered users with a free usage quota of OpenAI GPT series (200 messages). Before you exhaust this quota, you need to apply for your own API key through the official channels of the model provider. The key can be entered in Dify's [Settings] --> [Model Provider].
Step 1: Create an [Assistant] application
Switch to Assistant mode. Assistant can use Chain-of-Thoughts and Function Calling to use external tools to handle multi-step complex scenarios.
Step 2: Prompt engineering
First, let's plan how the Agent will work first, it needs to understand three things first:
Where do the users want to go?
How many days would they like to travel?
And the budget.
Based on the above information, we can start writing prompts. Here is a recommended prompt structure that makes your intention clearer to the LLM, yielding the desired content.
Here you can see our prepared prompts. You can also visit Dify.AI and register to test the prompts yourself (we recommend using the latest GPT model, currently gpt-4-1106-preview, for better results). Just copy and paste the prompts below into the [Prompt] window.
Step 3: Configure the tools used by our agent
It's very simple, Dify has already integrated a range of practical tools. Just select these tools and add them to your application for use. In this example, three tools that might be used are:
Wikipedia (Wikipedia search): For AI to query information about travel destinations, cities, tourist attractions, etc.;
Google (Google search): For AI to query real-time restaurant, hotel, and review information, making recommendations to users;
Web scraping (web crawler): Provides an optional tool for AI to extract useful web page information.
If you canot see Tools on the right panel, make sure the mode has been switched to [Agent Assistant], and is not [Basic Assistant].
While the Agent is working, it will autonomously analyze the steps to solve the problem and decide which tools to use to gather information.
Note here, if you want to use the Google search tool, you need to register at their website and get a SerpAPI key, then click [Authorize] for it to work properly. Here's an example of how to add a tool, using Google search.
Step 4: Choose the appropriate model
Choosing the right large model is crucial for an AI application. An optimal model needs to consider the model's context length, inference capabilities, and overall performance, as well as how to maximize its effect in practical applications. Dify, as an AI platform, supports all the mainstream Large Language Models (LLMs) on the market, allowing users to choose the most suitable one according to their specific needs.
When selecting an AI model, first consider the model's context length, which determines how much text the model can process. For applications that need to understand and generate longer texts, choose a model with a longer context length. Next, consider the model's inference capabilities, i.e., the speed and accuracy with which the model processes and responds to queries. Different models have entirely different capabilities and quality of output for different types of data.
Each model has their unique features. To help users make the best choice, Dify also offers an innovative feature - ChatHub - allowing users to compare the performance of different models under the same conditions. In this way, users can see the advantages and limitations of each model intuitively, making a wiser choice. Users can choose the most suitable model based on their needs – such as response speed, accuracy, and the ability to handle complex queries.
Simply click on the model, then click on [Multiple Models for Debugging] to enter the debugging interface. Here, a simple comparison of a single output from GPT-4 and GPT-3.5 clearly shows that the answer generated by GPT-4 is different from that of GPT-3.5 in terms of writing style, length, and output quality.
In situations where cost is not a constraint, we recommend choosing the most advanced model currently available, gpt-4-0125-preview. Such a model will ensure that your input and output are not limited and can achieve the best results. If cost is a concern, then choose a model based on your budget, such as the more cost-effective gpt-3.5-turbo, Claude; domestic models like Baichuan, Zhichu, and Minimax. Dify currently supports all mainstream open-source and closed-source models, so you can choose the one that suits your needs and preferences.
Step 5: Publish the Agent
After writing the prompt, remember to click "Publish" to save all changes. Once published, your Agent can be put into use at any time.
If you feel that this intelligent assistant does not meet your needs, try modifying the prompt. You can start with our template and change it to your style, such as changing its output text style, modifying the generated text template, or customizing new Tools to introduce new data sources.
How to put it into use?
After completing the above steps, how do we integrate this travel planning assistant into the existing workflow? Select "Overview" in the left sidebar, where we offer two methods:
Ready-to-use AI WebApp, you can copy the link to the browser for a trial.
Or backend service API, which can be integrated into the backend of your application.
How to Update and Maintain the Agent?
To better solve users' problems, we can actually update the Agent with a series of complex functions or add other Tools to enhance its capabilities:
Firstly, we can let users provide more information, such as through a series of questions to let users provide more details. For example, arrange suitable hotels and transportation according to the number of people, or plan suitable play projects and itinerary intensity according to age (such as the elderly or children). For example, it's completely unrealistic for a family of four to include an 18-kilometer hike in a day in their travel plans. This is not feasible for children.
Secondly, we can increase the information sources for searches. We can introduce real-time travel planning and hotel booking sites, such as Google Map, Ctrip, Airbnb, etc., to provide users with more comprehensive information. For example, a user who wants to travel to Paris can book local hotels and popular restaurants directly through the Agent, saving a lot of effort.
Thirdly, add navigation to the attractions on the way, helping users clearly understand how to reach their destination. This way, when users plan to visit a famous attraction, they can see the location of the attraction in the application and how to get there from their current location.
Lastly, we can create a reasonable timeline for the output content and adjust and maintain it based on user feedback. This means that the Agent will provide a customized itinerary based on the user's time schedule and preferences. For example, if a user wants to visit multiple attractions over a weekend, the Agent will ensure that the user can enjoy as many of them as possible within the limited time.
Start Building AI Assistants Now
Ever thought about creating your own AI Assistant? With Dify, you can start from build a new Assistant, opting for the Agent Assistant mode. Or, take an existing Chat App and switch it to Agent Assistant type right from its prompt setup page. Our docs are a great starting point for your adventure.
We're all for you exploring Dify to turn your one-of-a-kind ideas into reality. Whether you're building your own Agent Assistant or contributing new tools to us, we can't wait to see your creations.
Don’t forget to join our Discord community to share your thoughts and questions. We’re all ears!