Created
February 1, 2023 20:22
-
-
Save neopunisher/aad9e0260cf36dd8fcb6076e8ac9a360 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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