Using OpenAI API's in a Wappler project

Has anyone succeeded in using the OpenAI API with the Wappler Server Connect?

The quick start guide on their website works on Node.js but seems not to be compatible with Wappler as it uses React and ES6 on server side if I understood correctly. Any workaround to use it from a Wappler project would be highly appreciated

Actually, it seems quite straightforward.
1/ Create a Server Connect
2/ Under execute create an API Action
3/ Put the below settings

2 Likes

has anyone tested this? I have not been able to get it to run just yet…

I have used this in my project to have a play around here is what was working for me:

2 Likes

is there no way to add the prompt in the query values? as it is I don’t see how you could make the prompt dynamic. or am I missing something?

I see the prompt is dynamic on the last screenshot posted here:

It takes the value from a form input.

2 Likes

ah yes of course, I was reading too quick. thank you :slight_smile:

1 Like

I’m a bit unsure; is the form here being called form_chatgpt_promt or is it the text field?

It is a input in a form here is the post variable that links to my form input:

And here is how I bind the value

1 Like

thank you so much for the detailed reply. now I just have to sort out billing with openAI :).

1 Like

I’m still having issues (maybe I’m just daft…). Writing the prompt directly within the JSON works flawlessly, but passing it on from a form creates garbled output, sometimes returning totally different answers not relevant to the question, sometimes even code fragments (PHP or JSON).

what am I missing?

Screenshot 2023-05-03 at 20.57.44|690x382

What kind of questions are you asking i only ask because there is some limitations to ChatGPT I believe anything after 2021 has a warning it may not be accurate information. How about if you ask how many planets there are?

oh really simple stuff. there is definitely an issue with passing on the prompt from the form to the api. if I make the same prompt directly in the json field it works great.

Never tried this but lets just add a test here in the JSON add:

"echo": true,

Just below the max tokens

Hopefully this will return the prompt back along with the text just so we can see if the prompt was detected by ChatGPT or not

1 Like

I redid the whole server action. it is working now, although I do not know what is different to before… anyway, thank you very much for your help!

1 Like