Este mini paquete proporciona métodos auxiliares para interactuar con un modelo de idioma como CHATGPT, para generar algunas técnicas de ingeniería rápida repititiva. El por qué detrás de esto es que me cansé de escribir el mismo contexto en torno a mi aviso necesario. Exténtelo si te gusta.
https://www.npmjs.com/package/promptman
npm install promptman
La clase Promptman
tiene los siguientes métodos públicos:
resetInstructions()
- Restablece el atributo de inmediato.
zeroShotCOT()
: establece el atributo de inmediato para generar una respuesta para una cadena de pensamiento de disparo cero.
sentiment()
- Establece el atributo de solicitud para generar un análisis de sentimiento del texto.
stopWhenInDoubt
- se asegura de que GPT solo responda cuando su conocimiento fáctico
toResponseType()
: establece el tipo de respuesta que se devolverá.
toJson()
- Establece el tipo de respuesta al formato JSON.
text()
- Devuelve el texto después de ejecutar cualquier método.
La clase Promptman
se inicializa con un parámetro prompt
y se usa para interactuar con GPT o cualquier LLM simplemente. Los métodos de clase se pueden llamar de manera paso a paso para generar texto para diversos fines, como el análisis de sentimientos y la cadena de pensamiento de disparo cero.
Ejemplo 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 ( )
Texto generado
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' ] } .
Resultado
{
"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! "
}
]
}
Ejemplo 2 - Detente cuando esté en duda:
import { Promptman } from "promptman"
const text = new Promptman ( "what would be the best way to solve for global warming?" )
. resetInstructions ( )
. zeroShotCOT ( )
. stopWhenInDoubt ( )
. toJson ( )
. text ( )
Texto generado
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 .
Resultado
{
"response" : " I don't know "
}
Nota: Este archivo ReadMe se generó en función de la última versión del script disponible al momento de escribir.