@savant/prompting
v1.0.8
Published
A library for composing LLM Prompts and executing them.
Downloads
4
Readme
@savant/prompting
A library for composing LLM Prompts and executing them.
Variables
Variables can be defined within a prompt in the following format:
{{{variableName}}}
PtPrompt
const { PtPrompt } = require('@savant/prompting');
const prompt = await PtPrompt.load("./path/to/prompt.pt"); // creates a prompt from a file (.pt or .prompt)
const prompt = new PtPrompt(promptString); // creates a prompt from a string
const builtPromptStr = await prompt.build(anyVariablesInPrompt); // builds the prompt with the given variables
Model Modes
Chat
const { Chat } = require('@savant/prompting');
const chat = new Chat(prompt, messages, openai);
const response = await chat.execute(anyVariablesInPrompt, userMessageAsPrompt); // response is saved in messages
Completion
const { Completion } = require('@savant/prompting');
const completion = new Completion(prompt, openai);
const response = await completion.execute(anyVariablesInPrompt);