Skip to content

Instantly share code, notes, and snippets.

@neopunisher
Created February 1, 2023 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neopunisher/aad9e0260cf36dd8fcb6076e8ac9a360 to your computer and use it in GitHub Desktop.
Save neopunisher/aad9e0260cf36dd8fcb6076e8ac9a360 to your computer and use it in GitHub Desktop.
async (clipboardContentString) => {
try {
const response = await fetch("https://api.openai.com/v1/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR API KEY HERE"
},
body: JSON.stringify({
model: "text-davinci-003",
prompt: `${clipboardContentString}.`,
temperature: 0,
max_tokens: 256
})
});
const data = await response.json();
const text = data.choices[0].text;
return `${clipboardContentString} ${text}`;
} catch (error) {
return "Error"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment