search
テクノロジー

GPTの使い方(2) エディタのエラー修復方法

Apollon321's icon'
  • Apollon321
  • 2023/03/04 01:29

ジョンソンさんのコピペ改

const SECRET_KEY = "APIKEYS" ;

const MAX_TOKENS = 200;

// For more cool AI snippets and demos, follow me on Twitter: https://twitter.com/_abi_

/**

* Completes your prompt with GPT-3

*

* @param {string} prompt Prompt

* @param {number} temperature (Optional) Temperature. 1 is super creative while 0 is very exact and precise. Defaults to 0.4.

* @param {string} model (Optional) GPT-3 Model to use. Defaults to "text-davinci-003".

* @return Completion returned by GPT-3

* @customfunction

*/

function AI(prompt, temperature = 0.4, model = "text-davinci-003") {

const url = "https://api.openai.com/v1/completions";

const payload = {

model: model,

prompt: 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].text.trim();

}

console.log(AI("こんにちは!"));

/**

* Classifies an item into a fixed set of categories

* @param {range} categories Set of categories

* @param {string} item Item to classify

* @param {range} rules (Optional) Set of rules written in plain text

* @return Completion returned by GPT-3

* @customfunction

*/

function CATEGORIZE(categories, input, rules=[]) {

const prompt = "The available categories are " + categories.map((c) => `"${c}"`).join(", ") + ". " + rules.join(". ") + "The category for '" + input + "' is ";

console.log(prompt);

const completion = AI(prompt, 0, "text-davinci-003");

// Replace "s and .s at the start and end of the string

return completion.replace(/^"/g, '').replace(/["|.]{0,2}$/, '');

}

// For more cool AI snippets and demos, follow me on Twitter: https://twitter.com/_abi_

👆APIkeyの発券先

Content image

はい、エラー。始め””なのか’’なのかと思ってSTR関数?の誤認識かと思ったら、トークン不足の様だ。

無料は駄目!

という事らしい。

 

 

 

 

 

 

Article tip 0人がサポートしています
獲得ALIS: Article like 8.71 ALIS Article tip 0.00 ALIS
Article registration Article registration
Apollon321's icon'
  • Apollon321
  • @Apollon321
ALISって、何(・_・?)

投稿者の人気記事
コメントする
Loading...
コメントする
こちらもおすすめ!
Eye catch
クリプト

ジョークコインとして出発したDogecoin(ドージコイン)の誕生から現在まで。注目される非証券性🐶

昆布森ちゃん 2021/01/19
Like token Tip token
38.31 ALIS
Eye catch
ゲーム

ドラクエで学ぶオーバフロー

keiju togashi 2020/03/12
Like token Tip token
30.10 ALIS
Eye catch
クリプト

約2年間ブロックチェ-ンゲームをして

kaya 2021/10/06
Like token Tip token
61.20 ALIS
Eye catch
他カテゴリ

ALISのシステム概観

ALISブロックチェーンブログ 2018/07/03
Like token Tip token
5.00 ALIS
Eye catch
他カテゴリ

機械学習を体験してみよう!(難易度低)

nonstop-iida 2020/03/04
Like token Tip token
124.82 ALIS
Eye catch
テクノロジー

彼女でも分かるように解説:ディープフェイク

Jimmy 2020/03/17
Like token Tip token
32.10 ALIS
Eye catch
テクノロジー

なぜ、素人エンジニアの私が60日間でブロックチェーンゲームを制作できたのか、について語ってみた

ゆうき 2020/08/12
Like token Tip token
270.93 ALIS
Eye catch
テクノロジー

オープンソースプロジェクトに参加して自己肯定感を高める

おはぐろ氏 2020/02/15
Like token Tip token
85.05 ALIS
Eye catch
クリプト

Bitcoinの価値の源泉は、PoWによる電気代ではなくて"競争原理"だった。

CryptoChick 2020/03/07
Like token Tip token
159.32 ALIS
Eye catch
クリプト

Bitcoin史 〜0.00076ドルから6万ドルへの歩み〜

大田コウキ 2021/04/06
Like token Tip token
947.13 ALIS
Eye catch
クリプト

NFT解体新書・デジタルデータをNFTで販売するときのすべて【実証実験・共有レポート】

otakucoin 2021/03/29
Like token Tip token
121.79 ALIS
Eye catch
テクノロジー

iOS15 配信開始!!

IMAKARA 2021/09/23
Like token Tip token
7.20 ALIS