So I’ve found this instruction on how to implement ChatGPT in Google Sheets via function and AppScripts from a blog called Mindempire:
const SECRET_KEY = "YOUR API KEY";
const MAX_TOKENS = 800;
const TEMPERATURE = 0.9;
function AI_ChatGPT(prompt, temperature = 0.4, model = "gpt-3.5-turbo") {
const url = "https://api.openai.com/v1/chat/completions";
const payload = {
model: model,
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: prompt },
],
temperature: TEMPERATURE,
max_tokens: MAX_TOKENS,
};
const options = {
contentType: "application/json",
headers: { Authorization: "Bearer " + SECRET_KEY },
payload: JSON.stringify(payload),
};
const res = JSON.parse(UrlFetchApp.fetch(url, options).getContentText());
return res.choices[0].message.content.trim();
}
But how would I achieve the same with my prebuilt AI Assistants?
Thanks in advance.