@callmedayz/ai-prompt-toolkit
Version:
Professional AI prompt engineering toolkit with advanced template features, real-time dashboards, conditional logic, template inheritance, live monitoring, OpenRouter integration, and 310+ model support
110 lines • 3.21 kB
TypeScript
import { AdvancedPromptTemplate } from './advanced-prompt-template';
import { TemplateContext } from './types';
/**
* Template Composition System for Dynamic Prompt Building
* Enables combining multiple templates based on context and user behavior
*/
export declare class TemplateComposer {
private templates;
private compositionRules;
private context;
constructor(context?: TemplateContext);
/**
* Register a template with a unique name
*/
registerTemplate(name: string, template: AdvancedPromptTemplate): void;
/**
* Add a composition rule for dynamic template selection
*/
addCompositionRule(rule: CompositionRule): void;
/**
* Compose a prompt based on context and rules
*/
compose(context?: Record<string, any>): CompositionResult;
/**
* Create a composite template by combining multiple templates
*/
createComposite(templateNames: string[], separator?: string): AdvancedPromptTemplate;
/**
* Find templates that match the current context
*/
private findApplicableTemplates;
/**
* Select the best template from applicable ones
*/
private selectBestTemplate;
/**
* Evaluate if a composition rule applies to the current context
*/
private evaluateRule;
/**
* Evaluate a single condition
*/
private evaluateCondition;
/**
* Evaluate user behavior patterns
*/
private evaluateBehaviorPattern;
/**
* Get nested value from object using dot notation
*/
private getNestedValue;
/**
* Get all registered template names
*/
getTemplateNames(): string[];
/**
* Get composition statistics
*/
getStats(): CompositionStats;
}
export interface CompositionRule {
name: string;
templatePattern?: string;
conditions?: ContextCondition[];
behaviorPatterns?: BehaviorPattern[];
priority?: number;
description?: string;
}
export interface ContextCondition {
field: string;
operator: 'equals' | 'not_equals' | 'greater_than' | 'less_than' | 'contains' | 'exists' | 'in';
value: any;
}
export interface BehaviorPattern {
type: 'usage_frequency' | 'success_rate' | 'time_of_day' | 'domain_expertise';
threshold?: number;
timeRange?: [number, number];
domain?: string;
}
export interface ApplicableTemplate {
name: string;
template: AdvancedPromptTemplate;
priority: number;
appliedRules: string[];
}
export interface CompositionResult {
prompt: string;
templateName: string;
appliedRules: string[];
context: Record<string, any>;
metadata: {
compositionTime: string;
templateCount: number;
selectedPriority: number;
};
}
export interface CompositionStats {
templateCount: number;
ruleCount: number;
averagePriority: number;
}
/**
* Helper function to create common composition rules
*/
export declare function createCommonRules(): CompositionRule[];
/**
* Helper function to create a template composer with common rules
*/
export declare function createTemplateComposer(context?: TemplateContext): TemplateComposer;
//# sourceMappingURL=template-composition.d.ts.map