Page 2 of 2

Re: Openai (ChatGPT) from PB

Posted: Mon Aug 28, 2023 5:14 pm
by Caronte3D
Try to create an APIkey with a free account, I think in the past it was possible (don't know actually).

Re: Openai (ChatGPT) from PB

Posted: Wed Sep 06, 2023 2:58 am
by ricardo
jak64 wrote: Mon Aug 28, 2023 12:14 pm Thanks for the info Ricardo.
Have a nice day (even if the Argentinian beat France at football, I'm French) :D
Yoiu are welcome!!

That was a very nice soccer game!!

Re: Openai (ChatGPT) from PB

Posted: Thu Sep 07, 2023 12:23 am
by jak64
Hello Ricardo,
Indeed, good game.
See you soon

Re: Openai (ChatGPT) from PB

Posted: Tue Nov 14, 2023 9:22 pm
by Fig
Hi,
I tried it...
How long does it take to get an answer ?

It very very slow... more than 10 minutes !!
Can we get the answer letter by letter like in chatgpt instead of the whole long one ?

Re: Openai (ChatGPT) from PB

Posted: Wed Nov 15, 2023 4:07 pm
by ricardo
Fig wrote: Tue Nov 14, 2023 9:22 pm Hi,
I tried it...
How long does it take to get an answer ?

It very very slow... more than 10 minutes !!
Can we get the answer letter by letter like in chatgpt instead of the whole long one ?
}
Now you can connect using

Code: Select all

sModel.s = "gpt-3.5-turbo-1106"
That is fast.
You receive a JSON with the response.

The only problem is that, as happens with ChatGPT, you may receive uncertain information and that often does not follow the prompt instructions to the letter.


You can also use

Code: Select all

sModel = "dall-e-3"
And you will be able to prompt for images. Images are not as good as MidJourney, but its the start for something that may in the future create better images.

In the dall-e-3 model you will receive also a JSON response with the url of the image created.

Re: Openai (ChatGPT) from PB

Posted: Wed Nov 15, 2023 4:51 pm
by ricardo
Here is the code for generate images.

Code: Select all

          Procedure.s SendPrompt(sPrompt.s)
            sUrl.s = "https://api.openai.com/v1/images/generations"
            
            NewMap Header$()
            Header$("content-type") = "application/json"
            Header$("Authorization") = "Bearer YOURAPIKEY "
            
            nMaxTokens.l = 5000
            sModel.s = "dall-e-3"
            sNumberOfResponses = 1
            
            sTemperature.f = 0.9

            
            sBody.s = "{"
            sBody.s = sBody.s + Chr(34) + "model" + Chr(34) + ": " + Chr(34) + sModel + Chr(34) + ", "
            sBody + Chr(34) + "prompt" + Chr(34) + ": " + Chr(34) + sPrompt + Chr(34) + ", "
            sBody.s + Chr(34) + "n" + Chr(34) + ": " + Str(sNumberOfResponses) + ", "
            sBody + Chr(34) + "quality" + Chr(34) + ": " + Chr(34) + "hd" + Chr(34) + ", "
            sBody + Chr(34) + "size" + Chr(34) + ": " + Chr(34) + "1024x1024" + Chr(34)
            sBody.s + "}"
            
            ; Debug sBody
            

            Define httpReq
            
            httpReq = HTTPRequest(#PB_HTTP_Post, sUrl, sBody, 0, Header$())

            If httpReq

              Response$ = Trim(HTTPInfo(httpReq, #PB_HTTP_Response))
              Debug Response$
            EndIf
            
          EndProcedure
          
          lKeyword$= "Create and hipperrealistic image of a cat in the floor of a beautiful kitchen drinking milk in the sunsent hour HD"
          SendPrompt(lKeyword$)
Image