A flexible and efficient prompt management library for AI applications.
npm install prompt-manager
npx prompt-manager init
This will create a prompt-manager.config.js
file in your project root.
npx prompt-manager create MY_PROMPT -c MyCategory -t "This is a {{param}} prompt."
import { getPromptManager } from 'prompt-manager';
async function example() {
const promptManager = getPromptManager();
const summarizationPrompt = promptManager.Summarization.ARTICLE_SUMMARIZATION_PROMPT;
const formattedPrompt = summarizationPrompt.format({ articleContent: 'Your article content here' });
// Use the formatted prompt with your AI service
}
npx prompt-manager generate
This will generate TypeScript types based on your prompts.
You can customize Prompt Manager by editing the prompt-manager.config.js
file:
module.exports = {
promptsDir: '.prompts',
outputDir: 'src/generated',
typescript: true,
};
import { createPrompt } from 'prompt-manager';
async function createNewPrompt() {
await createPrompt('NEW_PROMPT', {
category: 'CustomCategory',
content: 'This is a {{customParam}} prompt.',
});
}
import { updatePrompt } from 'prompt-manager';
async function updateExistingPrompt() {
await updatePrompt('EXISTING_PROMPT', {
content: 'This is the updated {{param}} content.',
});
}
import { listPrompts } from 'prompt-manager';
async function listAvailablePrompts() {
await listPrompts();
}
import { generateTypes } from 'prompt-manager';
async function generateTypeDefinitions() {
await generateTypes();
}
- Centralized prompt management
- Type-safe prompt access and formatting
- Easy integration with AI services
- Customizable prompt structure
- Auto-generated types and implementation based on prompt definitions
To update the prompt library:
- Modify or add prompt JSON files in the
.prompts
directory - Run
npm run generate
to update the generated code - Build the project with
npm run build
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.