Этот мини -пакет предоставляет вспомогательные методы взаимодействия с языковой моделью, такой как 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 был сгенерирован на основе последней версии сценария, доступной на момент написания.