From the course: OpenAI API for Python Developers
Authentication and configuration
- [Instructor] Now the required step is to set up an API key that we're going to do by defining an environment variable right here. So we're going to replace this string with your own API key, and you also have the options to set it up this way. So let's go to the website, on the website to find here on the left sidebar, the section for the API keys. And remember that for any key that you have created, it's going to be encrypted so it's not visible. So in the case that you lose it or if it was compromised because you have exposed it publicly by mistake, the recommendation is to revoke it. So I'm going to click here to revoke my key and select revoke key. And here the step before I can do that is to confirm to solve this puzzle, to confirm that I am a human as opposed to being a bot. Okay, so verification done. So now it was revoked. So now I can create a new secret key so I don't have to name it. This is optional. I'm going to click on create a new secret key. Here again, I have to go through this puzzle. Okay, so very secure steps. So now this is again reminding you that you need to save this secret key and keep it somewhere safe and accessible, because remember that you're not going to be able to access it after you close this box. So we're going to make sure that we copy it in the clipboard and then when we are sure we can then click done. So let's go back to our projects and add it in the .env file. And I'm going to go ahead and rename this file right away because this is supposed to be an example template. So it needs to be dot.env like this. Here we go. And now let's go back to our projects. We're going to find here you see pass option. So we need to define here a new function which is going to be used to generate a completion. But for now, let's run the project because we want to see if this is working properly. So we're going to run the project with Python main.py and we want to make sure that the virtual environment is up and running like so. And we're going to click enter and here we go. So now you can see like the main interface for our AI chat bots, examples, you have two options, just like the previous example. So the first option is to start a chat, to start the conversation with AI, and the second option is to exit the program. The next step will be to configure the chatbot by setting up a system message. So that's going to be the next step. Let's go back here. So here we have an example. We're going to use the same example to define our chat bot application starting with a system message.
Contents
-
-
-
-
-
Introduction to conversational AI2m 26s
-
Project setup and overview3m 11s
-
Authentication and configuration2m 38s
-
Define a system message with instructions2m 11s
-
Making requests and generating chat completions6m 6s
-
Challenge: Create a funny chatbot2m 11s
-
Solution: Create a funny chatbot - part 14m 26s
-
Solution: Create a funny chatbot - part 24m 51s
-
-
-
-
-