OpenAI API: Program AI-based chats, sales assistants & text adventures
- How to let OpenAI's LLM speak in your websites, online stores and games
- The power behind ChatGPT - how to connect the OpenAI API to your developments
- Example chat: Program AI-based chat apps that interact with your users
- Example text adventure: Develop a game in which the NPCs give AI-generated answers
- Example sales assistant: How your online store talks to your users about products
- Programming chats based on AI - a three-hour tutorial by Stephan Haewß
Text generated by artificial intelligence - learn now how to incorporate it into your applications in a targeted and specific way.
36 Videos, 209 minutes
Introduction to the course
OpenAI API: 1 | What can you expect in the course?
3 minThis is what you can expect in this OpenAI API course.
Introduction
OpenAI API: 2.1 | Tools we will use
4 minThis video explains the tools used and the knowledge required.
OpenAI API: 2.2 | The OpenAI platform
5 minThis is about the OpenAI platform and how you can use it.
OpenAI API: 2.3 | IMPORTANT: Update of the OpenAI API and AstroJS
7 minThis is about the OpenAI update. Find out what changes have been made. Everything important is summarized in the project file.
Programming a chat app
OpenAI API: 3.1 | Creation of the AstroJS base project
5 minWe create our first project with npm create astro and take a look at the structure of the product.
OpenAI API: 3.2 | Adding React to our project
5 minSince we rely on React for our UI, Astro JS must first be enabled to use React components.
OpenAI API: 3.3 | Adding an endpoint to the server
4 minOur endpoint for the chat service will be a get requestto the URL /api/chat. We will set up this endpoint in this video.
OpenAI API: 3.4 | Preparing the OpenAI API call
11 minTo call the OpenAI API, we need an API key, which we can generate via our account with the OpenAI platform, as well as the openai-npm package.
OpenAI API: 3.5 | Transmission of the user message to the OpenAI API
5 minFor testing, we used a fixed text on the server. Here we want to use the text that is sent by the browser in the URL as a query parameter for the first time.
OpenAI API: 3.6 | Basic UI in React
7 minChatting only via the URL in the browser's address bar is not a permanent solution. That's why in this video we create a rudimentary React UI that allows you to enter the chat text.
OpenAI API: 3.7 | Saving the chat history
8 minWe haven't had a real chat yet, just a question and the answer to it. In order to have a productive conversation with the LLM, we need to memorize the chat history.
OpenAI API: 3.8 | Reset the chat
5 minSometimes you just want to start from the beginning and forget what was said. To avoid having to restart the server, we use a chat ID to reset the chat history on the server.
OpenAI API: 3.9 | Improve UX
9 minUntil now, chatting was still very rudimentary. Some improvements will be implemented here that will push our chat app a little more in the direction of ChatGPT.
OpenAI API: 3.10 | Beautify chat history
7 minThe chat history was not easy to read until now and is made a little "nicer" in this video.
OpenAI API: 3.11 | Summary: First chat app
2 minOur first chat app is now finished, but there is still a lot to do if you want to compete with ChatGPT ;-) If you don't want to do that, you can continue with a new project in the next section.
AI chat in a text-adventure game
OpenAI API: 4.1 | Creating the project
5 minWe are setting up the new project using our first chat app.
OpenAI API: 4.2 | The story
6 minA game needs a story. In this video, I present my idea for it and make initial preparations for navigating through the game.
OpenAI API: 4.3 | Prepare the quests
5 minThe player must complete three quests (chats) in order to reach the (temporary) end of the game. I prepare these in this video.
OpenAI API: 4.4 | The first AI chat
4 minThe bartender is the first chat partner in this game and is "brought to life" in this video.
OpenAI API: 4.5 | System prompt for the bartender
9 minUntil now, the bartender was somewhat clueless about his role in the game. We are remedying this by adding the first system prompt.
OpenAI API: 4.6 | Function calls
6 minOur chat partner has been absorbed in his role as bartender, but we do not yet know in the program whether the quest has been fulfilled by the player. This is where function calls come in handy, which the LLM can make of its own accord if it deems it appropriate. We have to make sure that it does this.
OpenAI API: 4.7 | Function calls: Provision of the result
6 minFunction calls can have return values and we also need to communicate these to the AI, which we do in this video.
OpenAI API: 4.8 | Mark quest as done
4 minThe client (browser) must be notified that the quest has been completed, because then the player can also talk to Dr. Owen and get a little closer to the goal.
OpenAI API: 4.9 | Leave the chat
9 minEven the best conversation must come to an end, but how do we get this into the program? By calling a function, of course.
OpenAI API: 4.10 | Talk to Dr. Owen
4 minFinally, the player can talk to the AI expert to find out the solution to the last puzzle.
OpenAI API: 4.11 | Start new chat on the server
8 minBartender and Dr. Owen are two different characters and are therefore not allowed to share a chat history. Therefore, we should create a new chat history for Dr. Owen.
OpenAI API: 4.12 | Provide new quest function for Dr. Owen
6 minDr. Owen needs a function so that we know that the player has asked for the solution to his little security robot problem and has received an answer. He gets it in this video.
OpenAI API: 4.13 | Chat with the security robot
9 minOur final opponent in this game is the security robot that didn't want to let us past the whole time. But now the player has the power, or rather the knowledge, to outwit him after all.
Virtual sales assistant for an online shop
OpenAI API: 5.1 | Creating the new project
8 minOur new project takes us into the world of guitar stores, of course with the friendly support of the OpenAI API, which allows us to realize a virtual sales assistant.
OpenAI API: 5.2 | Better product search
7 minSo far, the sales assistant has not been particularly good at providing advice. This is now to be improved with a simulated "database" using maps.
OpenAI API: 5.3 | More products
3 minPreviously we only had 2 products, which we increase to 4 in this video. The important thing here is that we now have several products per type and can therefore ask the sales assistant, for example, which electric basses are in the range.
OpenAI API: 5.4 | Multiple parameters in function calls
5 minPrice is not everything when buying a guitar, but a customer who does not want to take out a new mortgage on their own home should be able to ask the seller for electric guitars in the lower or middle price range. We achieve this with a second parameter priceRange in the corresponding function, which the LLM should then call.
OpenAI API: 5.5 | Fix for undefined price range
3 minWe broke it with the last video. But don't worry, the error is quickly fixed if you know where to look.
OpenAI API: 5.6 | Add product to shopping cart
5 minWhat would an online store be without a shopping cart? Although we won't be implementing a real shopping cart (that's not what this course is about), in this video we will lay the foundations so that you can connect a shopping cart to the virtual sales assistant. Here again ... the function call helps!
OpenAI API: 5.7 | Fuzzy product search
6 minIn most cases, customers will only know the approximate names of the products. The LLM can only make the function call with the names that appear in the customer's query. But with a little trick, the AI can be used quite easily for a "fuzzy" search in the product names for these cases.
Conclusion
OpenAI API: 6 | What has been learned, what else is there?
6 minA short summary of what we have achieved in this course, what you can do with it and what exciting APIs are still available in OpenAI.
Comment now „OpenAI API: Program AI-based chats, sales assistants & text adventures“