Skip to content

Instantly share code, notes, and snippets.

@albertohco
Forked from sergiolopes/gpt.js
Created June 25, 2023 22:55
Show Gist options
  • Select an option

  • Save albertohco/ea2c91e498191218d2b25c5cdffa486a to your computer and use it in GitHub Desktop.

Select an option

Save albertohco/ea2c91e498191218d2b25c5cdffa486a to your computer and use it in GitHub Desktop.
Use GPT no Google Spreadcheets com essa função App Script
const SECRET_KEY = "YOUR API KEY";
const MAX_TOKENS = 3000;
const TEMPERATURE = 0.9;
function EMAILALUNO(aluno, nota) {
const url = "https://api.openai.com/v1/chat/completions";
const payload = {
model: 'gpt-3.5-turbo',
messages: [
{ role: "system", content: "Crie um parágrafo de incentivo para um aluno que recebeu uma nota na prova. Vou passar o nome do aluno e a nota." },
{ role: "user", content: "Aluno: " + aluno + '. Nota: ' + nota },
],
temperature: TEMPERATURE,
max_tokens: MAX_TOKENS,
};
const options = {
contentType: "application/json",
headers: { Authorization: "Bearer " + SECRET_KEY },
payload: JSON.stringify(payload),
timeoutInSeconds: 60
};
const res = JSON.parse(UrlFetchApp.fetch(url, options).getContentText());
return res.choices[0].message.content.trim();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment