Create a Travel Assistant Chatbot using ChatGPT

Darren Broemmer
6 min readMay 13, 2023

You can use ChatGPT APIs in chat mode to easily build your own custom chatbot. There are a few things to understand when doing this.

First, the context for ChatGPT in these types of applications is the history of messages. It needs more than just the last statement entered by the user. Thus, the code builds up a list of chat history as it goes. On each API call, it provides ChatGPT with that history list as context.

Second, while the Davinci OpenAI model for coding tasks, we want to use the get-3.5-turbo or the latest gpt4 model is used for chat-based applications. Each model is fine-tuned and optimized for different use cases.

Also, the concept of roles is essential in chat applications.

In chat messages, there are three distinct roles: User, Assistant, and System.

  1. User: The User role represents the input or message provided by the human user interacting with ChatGPT. Users can ask questions, make requests, or engage in a conversation by providing prompts or messages to guide the Assistant’s responses. The User role initiates the conversation and sets the context for the Assistant to generate relevant replies.
  2. Assistant: The Assistant role represents the language model, such as ChatGPT, which generates responses based on the provided…

--

--

Darren Broemmer

I write weekly on puzzles, science, and technology. Technologist, published author, ex-BigTech, indie publisher.