Here we will show you how to use an instruct model from OpenAI as an API call instead of a completion model.
Step 1: Setting up API call for OpenAI’s ChatGPT
1. Navigate over to the plugins tab.
2. Expand your API call for Open AI.
3. Scroll down until you see the button “Add another call”
4. Click on the button “Add another call”
5. Give the new API call a name.
6. Click on the drop-down menu next to “Use as”, and select “Action.”
7. Click on the drop-down menu where it says “Name” and instead of POST select GET.
8. To the right of where it says “POST” copy the end point address of ChatGPT
Note: The end point address is different from the one used by Davinci and other completion models. Both addresses can be found here: https://platform.openai.com/docs/guides/gpt
Step 2: Specifying prompt and model parameters and importing them to Bubble
1. Log into your account on platform.openai.com
2. Write a prompt next to the slot where it says “User”.
3. Click on the button “View Code”.
4. In the window that appears, click on the side menu which says “curl”.
5. From the drop-down menu, select “json”.
6. Click on the button “copy”.
7. Paste the code into the window under “Body”.
8. Click on “Initialize call”
If all the steps were executed correctly, you should get this confirmation message.
Step 3: Modify the workflow which utilizes the new ChatGPT text generator
1. Switch over to the “Workflow” tab on the far left.
2. You will now replace the workflow involving the Davinci model with a workflow which involves ChatGPT. Click on the button responsible for the Davinci trigger.
3. Delete the steps of the Davinci workflow.
4. Click on the button “Click here to add an action…”
5. From the menu which appeared, select the option “Plugin” in the left column.
6. Select from the options the API call which you named in step 2.5. In our case, that name is “OpenAI - ChatGPT API Call”
7. In the menu that appeared, click on the menu next to “(body) input”.
8. A blue button will appear which says “Insert dynamic data.” Click on it.
9. In the drop-down menu which appears, select the option “Input <what you chose for the variable name in step 4.4 of the original app creation manual>”. In our case, that variable name is also “input” so our choice will be “Input input…”.
10. Click on the option “ ‘s values”.
11. Close that menu.
12. Click on the next dotted rectangle titled “Click here to add an action…”
13. In the menu which appears, select the menu window next to the title “Element.”
14. In the gray window that will appear, select “Text A”.
15. Click on the menu to the right of the title “Custom state”. Then select the “response_gpt” state option which you specified in Step 7.15. (Or whatever name you gave in the that step)
16. Click on the drop-down menu next to the title “Value.”
17. Next select the option “Result of Step 1 (Open AI - API Call).
18. In the drop-down menu which appears afterwards, select “‘s choices”.
19. Next, select the menu item “ :each item’s message content”
20. Next, select the item “ :first item”
21. Close that window.
Congratulations! You have created an AI app with OpenAI’s ChatGPT!
Preview the experience
To see how the viewer will experience the app, click on the “Preview” button in the top-right corner.
Click on the “Generate” button you have created earlier and see if a text following the prompt you specified will appear.