Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function openai(cellContent, modelo, systemprompt) {
- var url = 'https://api.openai.com/v1/chat/completions';
- var headers = {
- "Content-Type": "application/json",
- "Authorization": "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
- };
- var data = {
- "model": modelo,
- "messages": [
- {
- "role": "system",
- "content": systemprompt
- },
- {
- "role": "user",
- "content": cellContent // Or replace this with your actual question
- }
- ]
- };
- var options = {
- "method" : "post",
- "headers": headers,
- "payload" : JSON.stringify(data)
- };
- var response = UrlFetchApp.fetch(url, options);
- var json = JSON.parse(response.getContentText());
- return json.choices[0].message.content; // This will return the answer from GPT-3.5-turbo
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement