llama-flow
Version:
The Typescript-first prompt engineering toolkit for working with chat based LLMs.
31 lines (30 loc) • 1.09 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const truthyValues = ['true', 'yes'];
const falsyValues = ['false', 'no'];
const formatPrompt = 'Respond to the below prompt only with the word "true" or "false", nothing else.';
function buildRawPrompt(prompt) {
return {
message: `${formatPrompt}\n\n${prompt.message}`,
parse: async (response) => {
const cleaned = response.content
.replace(/\.|"|'/g, '')
.toLowerCase()
.trim()
.split(' ')[0];
if (truthyValues.includes(cleaned)) {
return { success: true, data: true };
}
else if (falsyValues.includes(cleaned)) {
return { success: true, data: false };
}
else {
return {
success: false,
retryPrompt: 'Respond to the prompt above with only the word "true" or "false", nothing else.',
};
}
},
};
}
exports.default = buildRawPrompt;
;