API Reference
Complete API reference for Prompt Manager - Auto-generated from TypeScript
API Reference
Complete API documentation for all Prompt Manager packages, auto-generated from TypeScript definitions.
Core Package
PromptManagerConfig
Configuration options for initializing the PromptManager.
Prop
Type
Core Interfaces
StorageAdapter
All storage adapters must implement this interface:
Prop
Type
TemplateAdapter
All template adapters must implement this interface:
Prop
Type
CacheAdapter
All cache adapters must implement this interface:
Prop
Type
Core Types
PromptDefinition
Structure for defining a prompt template.
Prop
Type
RenderOptions
Options for rendering a prompt.
Prop
Type
Message
Message structure for chat-based prompts.
Prop
Type
Template
Template structure with system, user, and example messages.
Prop
Type
ExecutionData
Data recorded when a prompt is executed.
Prop
Type
ExecutionRecord
Full execution record with ID and timestamp.
Prop
Type
Metrics
Aggregated metrics for prompt performance.
Prop
Type
Usage Examples
Basic Setup
import { PromptManager } from '@prompt-manager/core';
import { MemoryStorage } from '@prompt-manager/storage-memory';
import { SimpleTemplate } from '@prompt-manager/template-simple';
const manager = new PromptManager({
storage: new MemoryStorage(),
templates: new SimpleTemplate(),
});Registering and Rendering Prompts
// Register a prompt
await manager.register({
definition: {
name: 'greeting',
version: '1.0.0',
template: {
user: 'Hello, {{name}}!',
},
},
});
// Render the prompt
const result = await manager.render({
name: 'greeting',
options: {
variables: { name: 'World' },
},
});
console.log(result.messages); // [{ role: 'user', content: 'Hello, World!' }]Tracking Execution
const execution: ExecutionData = {
promptName: 'greeting',
version: '1.0.0',
variables: { name: 'World' },
response: 'Hi there!',
latencyMs: 150,
cost: 0.0001,
};
await manager.logExecution({ data: execution });Querying Metrics
const metrics = await manager.getMetrics({
filters: {
promptName: 'greeting',
version: '1.0.0',
},
});
console.log(metrics.executionCount);
console.log(metrics.avgLatencyMs);
console.log(metrics.totalCost);