「Google/スプレットシート/ChatGPT」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→サンプルコード) |
(→モデルについて) |
||
| 行37: | 行37: | ||
2023/1時点の最新 | 2023/1時点の最新 | ||
2022年11月に公開された"text-davinci-003" | 2022年11月に公開された"text-davinci-003" | ||
| + | |||
| + | ===モデル一覧=== | ||
| + | <pre> | ||
| + | モデル | ||
| + | Ada | ||
| + | Text-Ada-001 | ||
| + | Babbage | ||
| + | Text-Babbage-001 | ||
| + | Curie | ||
| + | Text-curie-001 | ||
| + | Davinci* | ||
| + | Text-davinci-001 | ||
| + | Text-davinci-002 | ||
| + | Text-davinci-003 | ||
| + | Text-davinci-fine-tune-002* | ||
| + | </pre> | ||
==参考== | ==参考== | ||
2023年1月30日 (月) 10:28時点における版
サンプルコード
/**
* GPT-3 and Google Sheets
*
* @param {string} prompt Prompt.
* @param {number} temperature (Optional) Temperature.
* @param {string} model (Optional) GPT-3 Model.
* @return Response returned by GPT-3.
* @customfunction
*/
const SECRET_KEY = "ここにAPIkeyをペースト";
//const MAX_TOKENS = 10;
const MODEL_NAME = "text-davinci-003";
const MODEL_TEMP = 0.3;
function GPT(prompt,max_tokens=30) {
const url = "https://api.openai.com/v1/completions";
const payload = {
model: MODEL_NAME,
prompt: prompt,
temperature: MODEL_TEMP,
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].text.trim();
}
上のスクリプトを、拡張機能のAppsScriptへ、貼り付ける。
モデルについて
2023/1時点の最新
2022年11月に公開された"text-davinci-003"
モデル一覧
モデル Ada Text-Ada-001 Babbage Text-Babbage-001 Curie Text-curie-001 Davinci* Text-davinci-001 Text-davinci-002 Text-davinci-003 Text-davinci-fine-tune-002*
参考
https://liquidjumper.com/google-sheets/googlespreadsheet_connect_to_gpt_3
https://bamka.info/googlespreadsheet-chatgpt-kansu/
ChatGPTのAPIはない https://auto-worker.com/blog/?p=7007
各種パラメータについて https://data-analytics.fun/2021/12/01/gpt-3-api/
モデル一覧 https://learn.microsoft.com/ja-jp/azure/cognitive-services/openai/concepts/models
