ChatGPT integration examples?
Posted: Sun Apr 30, 2023 2:35 am
I'm trying to integrate a ChatGPT query in my X#/VO/Winform application - I'm sure some of the group must've done this already.
I'm making a function to use ChatGPT to elaborate on a basic summary of a job that will be seeded by including some facts and details -customer name, address of a venue, and some other information about the equipment and what the event is achieving.
I've tried a couple of libraries and they look good: https://github.com/D7EAD/liboai, and https://www.nuget.org/packages/OpenAI/
Linked the api library as a reference in my app and Added USING OpenAI_API at the top, but that's about it.
I'm stuck declaring the Vars correctly... <yes, I do have an API key>
Here's the thing below that I'm trying to achieve but declaring those Vars... other than that I think the general idea is (almost) correct. (this is in a winform)
METHOD PBOpenAIClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL request AS ???
LOCAL Openai AS ???
LOCAL Response AS ???
openai := OpenAI.OpenAIAPI{(" <my API Key> ")}
request := CompletionRequest{}
request:Model := "text-davinci-002"
request:Prompt := "Acting as a copywriter, write a description of an event in about 200 words, in the style of a summary. The Date and times are 'XYZ', The location and organiser is: 'ZYX', and... "
request:MaxTokens := 50
request:Temperature := 0.7
response := openai:Completion:Create(request)
textbox{,,AsString(response:Choices[0])}:show()
RETURN
Can anyone share a snippet of syntax and point out a library they use to do something similar already?
Thank you.
Jonathan
I'm making a function to use ChatGPT to elaborate on a basic summary of a job that will be seeded by including some facts and details -customer name, address of a venue, and some other information about the equipment and what the event is achieving.
I've tried a couple of libraries and they look good: https://github.com/D7EAD/liboai, and https://www.nuget.org/packages/OpenAI/
Linked the api library as a reference in my app and Added USING OpenAI_API at the top, but that's about it.
I'm stuck declaring the Vars correctly... <yes, I do have an API key>
Here's the thing below that I'm trying to achieve but declaring those Vars... other than that I think the general idea is (almost) correct. (this is in a winform)
METHOD PBOpenAIClick(sender AS System.Object , e AS System.EventArgs) AS VOID
LOCAL request AS ???
LOCAL Openai AS ???
LOCAL Response AS ???
openai := OpenAI.OpenAIAPI{(" <my API Key> ")}
request := CompletionRequest{}
request:Model := "text-davinci-002"
request:Prompt := "Acting as a copywriter, write a description of an event in about 200 words, in the style of a summary. The Date and times are 'XYZ', The location and organiser is: 'ZYX', and... "
request:MaxTokens := 50
request:Temperature := 0.7
response := openai:Completion:Create(request)
textbox{,,AsString(response:Choices[0])}:show()
RETURN
Can anyone share a snippet of syntax and point out a library they use to do something similar already?
Thank you.
Jonathan