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文件是根据编写时可用的最新版本生成的。