Text generated by artificial intelligence - learn now how to incorporate it into your applications in a targeted and specific way.
This is what you can expect in this OpenAI API course.
This video explains the tools used and the knowledge required.
This is about the OpenAI platform and how you can use it.
This is about the OpenAI update. Find out what changes have been made. Everything important is summarized in the project file.
We create our first project with npm create astro and take a look at the structure of the product.
Since we rely on React for our UI, Astro JS must first be enabled to use React components.
Our endpoint for the chat service will be a get requestto the URL /api/chat. We will set up this endpoint in this video.
To 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.
For 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.
Chatting 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.
We 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.
Sometimes 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.
Until 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.
The chat history was not easy to read until now and is made a little "nicer" in this video.
Our 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.
We are setting up the new project using our first chat app.
A game needs a story. In this video, I present my idea for it and make initial preparations for navigating through the game.
The player must complete three quests (chats) in order to reach the (temporary) end of the game. I prepare these in this video.
The bartender is the first chat partner in this game and is "brought to life" in this video.
Until now, the bartender was somewhat clueless about his role in the game. We are remedying this by adding the first system prompt.
Our 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.
Function calls can have return values and we also need to communicate these to the AI, which we do in this video.
The 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.
Even the best conversation must come to an end, but how do we get this into the program? By calling a function, of course.
Finally, the player can talk to the AI expert to find out the solution to the last puzzle.
Bartender 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.
Dr. 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.
Our 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.
Our 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.
So far, the sales assistant has not been particularly good at providing advice. This is now to be improved with a simulated "database" using maps.
Previously 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.
Price 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.
We broke it with the last video. But don't worry, the error is quickly fixed if you know where to look.
What 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!
In 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.
Comment now „OpenAI API: Program AI-based chats, sales assistants & text adventures“