Created
September 19, 2024 15:55
-
-
Save alongubkin/c2619a74fe8a2a4cd65f55b87f4965c4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* @customfunction | |
*/ | |
async function completion(content: string) { | |
const response = await fetch("https://api.openai.com/v1/chat/completions", { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer <OPENAI_API_KEY>" | |
}, | |
body: JSON.stringify({ | |
model: "gpt-4o", | |
temperature: 0, | |
messages: [ | |
{ | |
role: "system", | |
content | |
} | |
] | |
}) | |
}); | |
const result = await response.json(); | |
return result["choices"][0]["message"]["content"]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment