R&D
11 May 2023
Project Faust - Creating a Sentient AI with ChatGPT and AWS Lex
Blog Hero

Introduction

After the initial excitement surrounding ChatGPT, I began contemplating ways to maximize the potential of this technology. As a solution architect, problem-solving is part of my daily routine, but identifying a problem that can be solved with the GPT model is another challenge altogether.

During this time, I attended a theatrical performance of "Faust," a satirical take on Goethe's masterpiece. While watching the play, I had an epiphany - Faust, a brilliant academic, was in search of infinite knowledge, and Mephistopheles (whom I shall now refer to as Mephisto) was lurking in the shadows, leading Faust towards various desires.

Drawing from this analogy, it occurred to me that we could merge ChatGPT (Faust) with AWS Lex (Mephisto) to create a single, all-capable Artificial Intelligence.

At present, OpenAI's Chat Completion API has three distinct roles: User, System, and Assistant. The System role provides the AI's context, information, and behavioral rules. The User role pertains to the input provided, while the Assistant role refers to the GPT Model's response. If you use ChatGPT, you will only see the Assistant and User sections, as the System role is reserved for OpenAI. However, at the API level, you can not only define the System but also make it appear as a third-person context.

This methodology is crucial to set the stage for "Mephisto." Although AWS Lex is not inadequate for the job, it is undeniably more "robotic" compared to GPT. The primary difference is that AWS Lex can communicate with databases, perform API calls, and process orders independently. As a result, we will leverage this tool to create our sentient AI.

High Level Architecture

Now that we have established the analogy, we can delve into the technical aspect. As shown above, the nodes illustrate the flow of data. The most critical element of this architecture is AWS Lex's Intent Engine. This engine enables AWS Lex to comprehend the user's intention and determine the appropriate course of action. This feature is vital in keeping the GPT Model in check. If the context information is not provided correctly, the model may generate information independently, which is known as "hallucination" in the AI world.

To comprehend the structure, we must elaborate on the design of AWS Lex Intents.

AWS Lex receives user input and, with its trained model of utterances, selects the appropriate "Intent" to follow. This is where we depart from the conventional Lex Bot design and adopt the "Faustian" design. Typically, for every user action, there is an intent, and the utterances describe how the user can express their intent. With the "Faustian" design, we create an intent for each API endpoint, combined with its methods. Additionally, we only employ three elements in the intents: Utterances, Slots, and Fulfillment.

As previously mentioned, utterances are how Lex comprehends the intent. Slots represent the parameters required to fulfill the intent. If a slot is not filled, the bot politely responds with "Information missing." Please refer to the demo below to observe how Mephisto (Lex) manipulates Faust (GPT) to fulfill the missing parameter.

The demo illustrates that by instructing GPT to "Ask the user about the 13-digit order ID," it will request the order ID from the user. Without this instruction, GPT would pose various questions and would not behave in a suitable manner. Moreover, after Lex provides the "real-time data," GPT has an updated context of the situation and can provide a human-like response to the user.

Additionally, a demonstration is available for "Order not found" and "Order delivered":

Here is Order Not Found:

At Sonne Technology, we are thrilled to provide cutting-edge assistance in setting up Project Faust for your company. Our innovative solution empowers you to establish your own help desk agent, salesperson, or marketing persona – all with the ultimate goal of boosting your business's bottom line.

Our dynamic team of experts is poised to develop, integrate, and operate this revolutionary technology in any industry with a wide audience. Whether you're a small start-up or a multinational corporation, we've got you covered.

With Project Faust in your arsenal, you'll be equipped to deliver exceptional customer service, enhance your sales funnel, and supercharge your marketing game. Say goodbye to the limitations of traditional business models and hello to the limitless potential of AI-powered communication.

Contact us today to learn more about how we can help you unleash the full power of Project Faust and revolutionize the way you do business.

Who are we?

Sonne Technology was founded in 2021 with the mission of providing cloud based solutions and consultancy services to businesses. Our focus is on creating Function as a Service (Serverless) products that offer customers an easy-to-manage, stress-free experience. We specialize in working with startups and SMEs, where flexibility and cost-effectiveness are key. Our team is ready to take on any challenge in an ultra-agile environment. We are dedicated to creating a community of growth and mutual support.

A brief anecdote

During the development of the demo, we had a bit of a momentary lapse and forgot to append the earlier messages to the message list. This resulted in GPT and Lex getting into a bit of a tiff.

Let's just say things got a little heated:

After a bit of bickering, we finally sorted things out and got them back on track. Lesson learned – always append your earlier messages, or you might end up with some feisty AI on your hands.

Continue Reading