The ChatGPT API program takes two optional variables, prompt_for_chatgpt
and the model to use. The simplest program that would allow your users to ask two consecutive questions would be:
*program: ChatGPT API - public
*clear
*if: success_chatgpt = 1
*{"RESPONSE FROM CHATGPT:"}*
{response_from_chatgpt}
*if: success_chatgpt = 0
*{"ERROR FROM THE CHATGPT API:"}*
{error_from_chatgpt}
*button: Click here to ask a second question!
*program: ChatGPT API - public
*clear
*if: success_chatgpt = 1
*{"RESPONSE FROM CHATGPT:"}*
{response_from_chatgpt}
*if: success_chatgpt = 0
*{"ERROR FROM THE CHATGPT API:"}*
{error_from_chatgpt}
If you don't set the prompt, the user gets to enter it. If you want to build the prompt based on the answers of your program's users, you'll save their answer into a different variable, and then build the prompt for ChatGPT, for example:
*question: Enter a short sentence
*save: sentence
>>prompt_for_chatgpt = "Give me a sentence that rhymes with: {sentence}"
*program: ChatGPT API - public
What is happening here is that the user gets to enter a sentence that is saved into a variable called sentence
. Then, the variable prompt_for_chatgpt
is generated, incorporating the value of sentence
(the curly brackets around a variable make it output its value). When the program ChatGPT API is run, the variable prompt_for_chatgpt
is set so you will notice that the question that was displayed before, ins not displayed now.
Regarding the error message you were getting, the problem is that you copied and pasted the code including the *label
, which is like a bookmark and has to be unique. You can omit the *label
if you don't have a *goto
statement.