Open sirkitree opened 3 years ago
I found this library we may be able to use, or at least look at further to see if ti will suit our needs: https://github.com/openai/GPT-3-Encoder
Also found some sample code here: https://www.twilio.com/blog/lyrics-javascript-openai-gpt3-twilio-functions
looks like that uses a library called 'got' to make the requests: https://www.npmjs.com/package/got
const got = require('got');
exports.handler = function(context, event, callback) {
let message = "";
let twiml = new Twilio.twiml.MessagingResponse();
const prompt = event["prompt"]
got.post('https://api.openai.com/v1/engines/davinci/completions', {
json: {
"prompt": prompt,
"max_tokens": 50,
"temperature": 0.9,
"top_p": 1,
"presence_penalty": 0.4,
"frequency_penalty": 0.75,
"stop": "\n",
},
headers: {
'Authorization': `Bearer ${context.OPENAI_SECRET_KEY}`,
}
})
.json()
.then(response => {
message = response.choices[0].text
})
.catch(error => {
console.log(error);
message = "Oops! Something went wrong.";
})
.finally(() => {
twiml.message(message);
callback(null, twiml);
});
};
Here's a Node library to help: https://www.npmjs.com/package/openai-api
Note: the following is not an endpoint but is a process we will have to figure out in how to send and receive data from GPT-3.
When we receive the quantum data we will need to then send this data to GPT-3.
And then record the response from GPT-3