توفر هذه الحزمة المصغرة طرقًا للمساعد للتفاعل مع نموذج لغة مثل 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 بناءً على أحدث إصدار من البرنامج النصي المتاح في وقت كتابة هذا التقرير.