Ce mini package fournit des méthodes d'assistance pour interagir avec un modèle de langue comme Chatgpt, pour générer des techniques d'ingénierie rapide répète. Le pourquoi derrière, est-ce que je suis fatigué d'écrire le même contexte autour de mon invite nécessaire. Prolongez-le si vous l'aimez.
https://www.npmjs.com/package/promptman
npm install promptman
La classe Promptman
a les méthodes publiques suivantes:
resetInstructions()
- Réinitialise l'attribut d'invite.
zeroShotCOT()
- Définit l'attribut invite pour générer une réponse pour une chaîne de pensée zéro-shot.
sentiment()
- Définit l'attribut d'invite pour générer une analyse de sentiment du texte.
stopWhenInDoubt
- s'assure que GPT ne répondrait que lorsque son Knowlledge facutal ne serait
toResponseType()
- Définit le type de réponse à retourner.
toJson()
- Définit le type de réponse au format JSON.
text()
- renvoie le texte après avoir exécuté n'importe quelle méthode.
La classe Promptman
est initialisée avec un paramètre prompt
et est utilisée pour interagir avec GPT ou n'importe quel LLM simplement. Les méthodes de classe peuvent être appelées de manière étape par étape pour générer du texte à diverses fins comme l'analyse du sentiment et la chaîne de pensée zéro-shot.
Exemple 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 ( )
Texte généré
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' ] } .
Résultat
{
"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! "
}
]
}
Exemple 2 - Arrêtez-vous en cas de doute:
import { Promptman } from "promptman"
const text = new Promptman ( "what would be the best way to solve for global warming?" )
. resetInstructions ( )
. zeroShotCOT ( )
. stopWhenInDoubt ( )
. toJson ( )
. text ( )
Texte généré
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 .
Résultat
{
"response" : " I don't know "
}
Remarque: Ce fichier ReadMe a été généré en fonction de la dernière version du script disponible au moment de la rédaction.