promptman
1.0.0
這個迷你軟件包提供了與ChatGpt這樣的語言模型進行交互的幫助方法,以生成一些重新有效的及時工程技術。背後的原因,我厭倦了在所需的提示上寫相同的上下文。如果您喜歡它,請擴展它。
https://www.npmjs.com/package/promptman
npm install promptman
Promptman
類具有以下公共方法:
resetInstructions()
- 重置提示屬性。
zeroShotCOT()
- 設置用於生成零擊鍊鍊的響應的提示屬性。
sentiment()
- 設置用於生成文本情緒分析的提示屬性。
stopWhenInDoubt
確保GPT僅在其facutal nowlledge時才回答
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文件是根據編寫時可用的最新版本生成的。