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. If necessary, expand the More Advanced Settings section and enter the necessary values.

10. 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 "Send user latest messages"

The Send recent user messages switch allows you to save the context of the dialog that was before the ChatGPT component.

If the component is customized using roles only, you must copy the roles along with their content from the previous ChatGPT component to preserve the context. The setting Send user latest messages allows you not to do this.

Let's test the function Before the dialog.

In the Content field, we will write something for the neural network. You can fill in this field by writing the question as it is, in text, or output it as a variable that will have a question or statement for the neural network in the value. This must be done in order for the component to work, despite the fact that now the neural network will respond to what was sent to the bot before hitting the component with ChatGPT.

Let’s indicate the number of recent messages that ChatGPT will analyze for a response.

We will get to the screen with the ChatGPT component using a Template. The template in our example will be called by the phrase "Tell me something interesting".

According to this phrase, the Template in the bot will work and at the same time, “Tell me something interesting” will get into ChatGPT. An interesting fact will come in response.

Set the switch to the position After the dialog, and leave the rest of the settings the same. After that, we will call up the ChatGPT screen and get an answer to the question or phrase that is currently written in the Content field.

A question about the theory of relativity is written in the Content field, and ChatGPT sent an answer to it due to the fact that the After the dialog item was selected. The request before the dialog "Tell me something interesting" in the answer was not taken into account in this case.

You can come up with other scenarios for using the settings of Send user latest messages, based on the fact that the function Before the dialog will continue what was written to the bot before getting into ChatGPT, without taking into account Role and Content, and After the dialog will take information from the Role and Content fields.

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 as if we need to get an answer from a sports journalist:

To the beginning ↑