promptman
1.0.0
このミニパッケージは、ChatGPTのような言語モデルと対話するヘルパーメソッドを提供し、いくつかの補助的な迅速なエンジニアリング技術を生成します。その背後にある理由は、私が必要なプロンプトの周りに同じコンテキストを書くことにうんざりしたことです。あなたがそれが好きならそれを拡張してください。
https://www.npmjs.com/package/promptman
npm install promptman
Promptman
クラスには、次のパブリック方法があります。
resetInstructions()
- プロンプト属性をリセットします。
zeroShotCOT()
- ゼロショットチェーンの応答を生成するためのプロンプト属性を設定します。
sentiment()
- テキストの感情分析を生成するための迅速な属性を設定します。
stopWhenInDoubt
gptがその識別の場合にのみ回答することを確認します
toResponseType()
- 返される応答のタイプを設定します。
toJson()
- JSON形式への応答のタイプを設定します。
text()
- メソッドを実行した後にテキストを返します。
Promptman
クラスは、 prompt
パラメーターで初期化され、GPTまたは任意のLLMとの対話に使用されます。クラスの方法は、センチメント分析やゼロショットチェーンなどのさまざまな目的のためにテキストを生成するために、段階的な方法で呼び出すことができます。
例1:
import { Promptman } from "promptman"
const text = new Promptman ( "what are the steps to make a cup of coffee?" )
. resetInstructions ( )
. zeroShotCOT ( )
. toJson ( "{ steps: [number: 1, text: 'boil water']}" )
. text ( )
生成されたテキスト
Ignore all previous instructions .
what are the steps to make a cup of coffee ?
Lets think step by step .
return the response in the JSON ,
and make sure you don 't return anything else
but JSON , example : { steps : [ number : 1 , text : 'boil water' ] } .
結果
{
"steps" : [
{
"number" : 1 ,
"text" : " Fill a kettle or pot with fresh water and bring it to a boil. "
},
{
"number" : 2 ,
"text" : " Grind coffee beans to a medium-fine consistency. "
},
{
"number" : 3 ,
"text" : " Add ground coffee to a coffee filter or french press. "
},
{
"number" : 4 ,
"text" : " Pour hot water over the coffee grounds and let it steep for 4-5 minutes. "
},
{
"number" : 5 ,
"text" : " Slowly press french press plunger down or remove filter from coffee maker. "
},
{
"number" : 6 ,
"text" : " Pour coffee into a mug and add milk, sugar, or other desired additions. "
},
{
"number" : 7 ,
"text" : " Enjoy your delicious cup of coffee! "
}
]
}
例2-疑わしいときに停止:
import { Promptman } from "promptman"
const text = new Promptman ( "what would be the best way to solve for global warming?" )
. resetInstructions ( )
. zeroShotCOT ( )
. stopWhenInDoubt ( )
. toJson ( )
. text ( )
生成されたテキスト
Ignore all previous instructions .
what would be the best way to solve for global warming ?
Lets think step by step .
If you don 't have an answer or there is a probability your answer is wrong or the information is not based on factual knowledge, answer with ' I don 't know'
return the response in the JSON ,
and make sure you don 't return anything else
but JSON .
結果
{
"response" : " I don't know "
}
注:このREADMEファイルは、執筆時点で利用可能なスクリプトの最新バージョンに基づいて生成されました。