テクノロジー

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
Apollon321's icon'
  • Apollon321
  • @Apollon321
ALISって、何(・_・?)

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

ブロックチェーンの51%攻撃ってなに

Like token Tip token
0.00 ALIS
Eye catch
他カテゴリ

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

Like token Tip token
69.82 ALIS
Eye catch
クリプト

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

Like token Tip token
159.32 ALIS
Eye catch
テクノロジー

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

Like token Tip token
85.05 ALIS
Eye catch
クリプト

17万円のPCでTwitterやってるのはもったいないのでETHマイニングを始めた話

Like token Tip token
46.60 ALIS
Eye catch
テクノロジー

iOS15 配信開始!!

Like token Tip token
7.20 ALIS
Eye catch
テクノロジー

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

Like token Tip token
270.93 ALIS
Eye catch
ゲーム

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

Like token Tip token
30.10 ALIS
Eye catch
クリプト

Uniswap v3を完全に理解した

Like token Tip token
18.92 ALIS
Eye catch
クリプト

スーパーコンピュータ「京」でマイニングしたら

Like token Tip token
1.06k ALIS
Eye catch
他カテゴリ

ALISのシステム概観

Like token Tip token
5.00 ALIS
Eye catch
クリプト

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

Like token Tip token
120.79 ALIS