Ooh. Here are the docs. A quick first attempt using the simplest possible approach:
// #popclip
// name: GPT-3.5
// icon: iconify:logos:openai-icon
// language: javascript
// after: paste-result
// entitlements: [network]
// options: [{
// identifier: apikey, label: API Key, type: string,
// description: 'Obtain API key from https://platform.openai.com/account/api-keys'
// }]
const openai = require("axios").create({
baseURL: 'https://api.openai.com/v1/',
headers: { Authorization: `Bearer ${popclip.options.apikey}` }
});
const params = {
model: 'gpt-3.5-turbo',
messages: [{ "role": "user", "content": popclip.input.text }]
};
const { data } = await openai.post('chat/completions', params);
return popclip.input.text + data.choices[0].message.content;
It uses the newly released gpt-3.5-turbo
model, but it only works as a “one shot” question i.e. it doesn’t remember what the previous chat was. I need to look a bit more closely to see how to do that.