One of the exciting things about a large language model is that you can use it to build a custom chat bot with only modest amounts of effort. The web interface of GPT is a way for you to have a conversational interface via a large language model. But one of the cool things is that you can also use a large language model to build your own custom chat bot, such as an AI customer service agent or an AI order taker for restaurants. In this video, you will learn how to do that for yourself.
To build a chat bot with a large language model, you need to understand the components of the OpenAI chat completions format. The chat models, like ChatGPT, are trained to take a series of messages as input and return a model-generated message as output. The chat format is designed to make multi-turn conversations easy, but it is also useful for single-turn tasks without any conversation.
In order to build your own chat bot, you will need to define helper functions that handle the input and output of messages. One common helper function is the completion function, which takes a prompt as input and returns a completion. Another helper function is the one that handles a list of messages as input, allowing for more complex conversations.
When using the chat completions format, you need to provide a system message, which sets the behavior and persona of the assistant. It acts as a high-level instruction for the conversation and guides the assistant’s responses. The user messages are the input, and the assistant messages are the output.
In this video, a different helper function is used, which takes a list of messages as input. This allows for more flexibility in the conversation and makes it easier to provide context to the model. The system message helps to frame the conversation without making the request itself part of the conversation.
To demonstrate the use of messages in a conversation, examples are provided where the model is asked to tell a joke or answer a question. The responses from the model show how it can generate conversational and context-aware messages.
In order to automate the collection of user prompts and assistant responses, a helper function is defined that collects user messages and appends them to a list called context. This allows for the model to have the necessary information to determine what to do next in the conversation. The context can be built up over time, allowing for more complex interactions.
To further demonstrate the use of messages in a conversation, an example of building an Autobot chat bot for a pizza restaurant is shown. The system message provides instructions for the conversation, such as greeting the customer, collecting the order, and asking for additional information. The user messages are collected using a user interface, and the assistant responds accordingly.
Finally, the model can be asked to create a JSON summary of the conversation, which can be sent to the order system. The JSON summary includes the food order, itemized prices, and additional details. This demonstrates how the chat bot can be used to automate the collection and processing of orders.
In conclusion, building a custom chat bot with a large language model is an exciting and powerful capability. It allows for the creation of conversational interfaces and can be used in various applications, such as customer service agents or order takers. By understanding the chat completions format and using helper functions, you can build your own chat bot with ease.