Paket mini ini menyediakan metode penolong untuk berinteraksi dengan model bahasa seperti chatgpt, untuk menghasilkan beberapa teknik rekayasa cepat repititif. Mengapa di belakangnya, saya bosan menulis konteks yang sama di sekitar prompt saya yang dibutuhkan. Perpanjang jika Anda menyukainya.
https://www.npmjs.com/package/promptman
npm install promptman
Kelas Promptman
memiliki metode publik berikut:
resetInstructions()
- Reset atribut prompt.
zeroShotCOT()
- Mengatur atribut prompt untuk menghasilkan respons untuk rantai pemikiran nol -shot.
sentiment()
- Mengatur atribut prompt untuk menghasilkan analisis sentimen teks.
stopWhenInDoubt
- pastikan GPT hanya akan menjawab ketika facutal knowlledge
toResponseType()
- Mengatur jenis respons yang akan dikembalikan.
toJson()
- Menetapkan jenis respons ke format JSON.
text()
- Mengembalikan teks setelah menjalankan metode apa pun.
Kelas Promptman
diinisialisasi dengan parameter prompt
dan digunakan untuk berinteraksi dengan GPT atau LLM apa pun. Metode kelas dapat dipanggil dengan langkah demi langkah untuk menghasilkan teks untuk berbagai tujuan seperti analisis sentimen dan rantai pemikiran nol-shot.
Contoh 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 ( )
Teks dihasilkan
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' ] } .
Hasil
{
"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! "
}
]
}
Contoh 2 - Berhenti saat ragu:
import { Promptman } from "promptman"
const text = new Promptman ( "what would be the best way to solve for global warming?" )
. resetInstructions ( )
. zeroShotCOT ( )
. stopWhenInDoubt ( )
. toJson ( )
. text ( )
Teks dihasilkan
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 .
Hasil
{
"response" : " I don't know "
}
Catatan: File ReadMe ini dihasilkan berdasarkan versi terbaru dari skrip yang tersedia pada saat penulisan.