ChatGPT OpenAI request

The ChatGPT OpenAl request component sends a text from the user to ChatGPT and sends a response from the neural network to the bot.

Configuring the component

1. From the Components section on the right panel, drag or double-click the ChatGPT OpenAl Request component to the desired screen.

2. In the Access token, add the OpenAI token. You can get it in your Open AI personal account.

If OpenAl is not available in your country, use a VPN service.

3. In the drop-down list of the Role field, select the role that ChatGPT will perform.

  • system — the system message helps to configure the assistant behavior.
  • user — user messages help instruct the assistant. They can be generated by the end users of the chatbot.
  • assistant — assistant messages help to save previous responses.

4. Add to the Content field what you want to send to the neural network. In Content, you can output a variable that received the user input before executing the ChatGPT component. In ChatGPT, select the user role. It might look like this:

5. Add Variable name for the response, so that the response from ChatGPT OpenAI is transferred to the bot.

6. The number of the Max quantity of used tokens can be left by default or changed for a shorter or more detailed answer. The minimum value is 16, the maximum one is 4000.

7. Set the Variable name for the complete answer if you need to get a full response from ChatGPT. It is not necessary to fill in this variable.

8. Select or leave the default gpt -3.5-turbo model used or gpt-3.5 turbo-0301, but keep in mind that gpt-3.5-turbo-0301 does not always take into account the system role.

9. Configure the screen for a successful request. On this screen, we will display the answer from ChatGPT and ask a new question. The neural network will respond, taking into account the context of the last question, if the system role is added to the ChatGPT component, and the variable where the last answer was recorded is displayed in the Content field. So the system will understand what was discussed earlier and will give the appropriate response.

In order to ask another question, keeping the context, repeat this scenario again, remember to add variables to the system, where previous questions were recorded.

Setting up roles

In the assistant or system role, you can determine on behalf of whom we want to receive an answer. For example, on behalf of a translator, programmer, etc.

For an example of this behavior, let's write the response with the role of the neural network into a variable. You can do this by User Input or by writing variables in Write Variables so that the variable is transferred to the role automatically without user intervention.

Add the info variable to the Content ChatGPT field. Let's choose the assistant role so that the response is similar in style to live communication or system, if you need to configure the behavior of the neural network.

We will continue to ask questions. There may be several of them in a row for a more complete response from ChatGPT. In the case of several questions in a row, you need to write in the Content field all the variables where the questions were recorded, and select the user or assistant role. So the neural network will understand that these questions are united by one topic.

Let's write the response to the response variable and output this variable in the text

{{stringify response}}

Don't forget to save.

Let's test it. Let's inform the neural network that it is a translator:

In this case, ChatGPT answered the question in French. The assistant role was written in the component. We passed our response in the info variable to this role.

Change the role to system and you will see that the neural network translates the question into French: