แพ็คเกจขนาดเล็กนี้ให้วิธีการของผู้ช่วยในการโต้ตอบกับรูปแบบภาษาเช่น ChatGPT เพื่อสร้างเทคนิควิศวกรรมที่พร้อมท์ที่กลับมาใหม่ ทำไมอยู่ข้างหลังฉันรู้สึกเบื่อที่จะเขียนบริบทเดียวกันรอบ ๆ พรอมต์ที่ฉันต้องการ ขยายถ้าคุณชอบ
https://www.npmjs.com/package/promptman
npm install promptman
คลาส Promptman
มีวิธีการสาธารณะต่อไปนี้:
resetInstructions()
- รีเซ็ตแอตทริบิวต์ที่รวดเร็ว
zeroShotCOT()
- ตั้งค่าแอตทริบิวต์พรอมต์สำหรับการสร้างการตอบสนองสำหรับห่วงโซ่ความคิดแบบศูนย์
sentiment()
- ตั้งค่าแอตทริบิวต์พรอมต์สำหรับการสร้างการวิเคราะห์ความเชื่อมั่นของข้อความ
stopWhenInDoubt
- ทำให้แน่ใจว่า GPT จะตอบได้ก็ต่อเมื่อ facutal knowlledge ของมัน
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 นี้ถูกสร้างขึ้นตามสคริปต์เวอร์ชันล่าสุดที่มีอยู่ในขณะที่เขียน