I think a fixed prompt version of this may be very useful. Just as a proof of concept:
// #popclip
// name: OpenAI - Fixed Prompt
// icon: P
// 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'}
// - {identifier: prompt, label: Prompt, type: string,
// defaultValue: "Summarise the following in fewer words"}
const openai = require("axios").create({
baseURL: 'https://api.openai.com/v1/',
headers: { Authorization: `Bearer ${popclip.options.apikey}` }
});
const data = {
model: 'text-davinci-003',
max_tokens: 512,
prompt: popclip.options.prompt + ":\n\n" + popclip.input.text
};
const response = await openai.post('completions', data);
return response.data.choices[0].text.trim();
Example (with the default prompt “Summarise the following in fewer words”):
I used this same concept to make a German Sentence Case extension.