In this case, it's GPT 3.5 Turbo, and the message, which includes the user, and the content that will be the prompt. And at the end, it will just return the content with the first response, so that's all you need.
I'm going to do a demo using RunMeme. This extension was developed by my company, so if you can check it out, it will be great. So let's go here. I'm just going to do like a basic example of interacting with ChatGPT when I can ask ChatGPT questions for my terminal, and then ChatGPT will respond.
So this is the extension I was talking about, which is this button. You can run read-me's inside the BS Code. So if I click this button, you'll say, what type of chatbot would you like to create? So I would just be like, Steve Jobs ChatBot. So I say, hello, and then, hi there, I'm Steve Jobs ChatBot, how can I assist you today? So I will say, tell me something every developer should know. And then it will take a few seconds to call the API, and if internet is fast, it shouldn't take very long.
So how did I do this? Only with 38, 39 lines of code is able to do this. So first we import all the dependencies, then I create a new configuration based with the API key that was provided by openAI. Then I create a new AI API with the configuration, and I create an interface, but with an input and an output. The input would be my questions, the output would be the chatbot response, and then I have the first question, what type of chatbot would you like to create, this is what I say, Steve Jobs. And then I have the user input that says, say hello to new assistant. And these are some of the lines of code I said before, they're quite important, which is create chat completion with a message and a model, as we said before, we're going to use the GPT 3.5 turbo, that's the model that we're going to use. And here it will have the first response. Then here the user is prompted to enter the next input, and if there is no response from the API, it will say there is no response, please try again. And if there is an error, it will catch it here. And that's it. That's all you need to do to create, to integrate chatbot with Node.js. But it would be even cooler if I can just select from the CLI some avatars. For example, if I could pick from Leonardo da Vinci, or William Shakespeare, or Yoda, or Steve Jobs, like, that would be cool. So if I run this, I can choose from here. What type of chatbot would you like to create? So let's say I'm one Yoda. So it says, perfect, now tell me your question.
Comments