@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
186 lines • 5.09 kB
TypeScript
import { OpenRouterClient } from './openrouter-client';
import { CompletionConfig } from './openrouter-completion';
import { SupportedModel } from './types';
/**
* Represents a versioned prompt with metadata
*/
export interface PromptVersion {
id: string;
version: string;
name: string;
description?: string;
template: string;
variables: Record<string, any>;
metadata: {
createdAt: Date;
createdBy?: string;
tags?: string[];
parentVersion?: string;
isActive: boolean;
};
performance?: PromptPerformanceMetrics;
}
/**
* Performance metrics for a prompt version
*/
export interface PromptPerformanceMetrics {
totalTests: number;
successRate: number;
averageResponseTime: number;
averageTokenUsage: number;
averageCost: number;
qualityScore?: number;
lastTested: Date;
}
/**
* Configuration for A/B testing
*/
export interface ABTestConfig {
name: string;
description?: string;
variants: PromptVersion[];
trafficSplit: number[];
testDuration?: number;
successCriteria: {
metric: 'response_time' | 'token_usage' | 'cost' | 'quality_score' | 'success_rate';
target: number;
operator: 'greater_than' | 'less_than' | 'equals';
}[];
sampleSize?: number;
}
/**
* Result of an A/B test
*/
export interface ABTestResult {
testId: string;
config: ABTestConfig;
variants: {
version: PromptVersion;
metrics: PromptPerformanceMetrics;
testCount: number;
isWinner?: boolean;
}[];
startTime: Date;
endTime?: Date;
status: 'running' | 'completed' | 'stopped';
winner?: PromptVersion;
confidence: number;
summary: string;
}
/**
* Individual test execution result
*/
export interface TestExecution {
id: string;
promptVersionId: string;
input: string;
output: string;
responseTime: number;
tokenUsage: number;
cost: number;
success: boolean;
timestamp: Date;
metadata?: Record<string, any>;
}
/**
* Prompt Versioning and A/B Testing System
*/
export declare class PromptVersionManager {
private versions;
private activeTests;
private testExecutions;
private client?;
private completion?;
constructor(client?: OpenRouterClient);
/**
* Create a new prompt version
*/
createVersion(name: string, template: string, variables?: Record<string, any>, options?: {
description?: string;
tags?: string[];
parentVersion?: string;
createdBy?: string;
}): PromptVersion;
/**
* Get a prompt version by ID
*/
getVersion(id: string): PromptVersion | undefined;
/**
* List all versions of a prompt by name
*/
getVersionsByName(name: string): PromptVersion[];
/**
* Get the latest active version of a prompt
*/
getLatestVersion(name: string): PromptVersion | undefined;
/**
* Update a prompt version (creates a new version)
*/
updateVersion(parentId: string, updates: {
template?: string;
variables?: Record<string, any>;
description?: string;
tags?: string[];
}): PromptVersion;
/**
* Deactivate a prompt version
*/
deactivateVersion(id: string): void;
private generateId;
private generateVersionNumber;
/**
* Start an A/B test with multiple prompt versions
*/
startABTest(config: ABTestConfig): Promise<ABTestResult>;
/**
* Execute a test for a specific variant in an A/B test
*/
executeTest(testId: string, input: string, model?: SupportedModel, config?: CompletionConfig): Promise<TestExecution>;
/**
* Get the current status of an A/B test
*/
getTestStatus(testId: string): ABTestResult | undefined;
/**
* Stop an A/B test and analyze results
*/
stopABTest(testId: string): ABTestResult;
/**
* Complete an A/B test and analyze results
*/
completeABTest(testId: string): ABTestResult;
/**
* Get test executions for a specific test
*/
getTestExecutions(testId: string): TestExecution[];
/**
* Export prompt versions to JSON
*/
exportVersions(): string;
/**
* Import prompt versions from JSON
*/
importVersions(jsonData: string): void;
private validateABTestConfig;
private selectVariant;
private recordTestExecution;
private updateVariantMetrics;
private analyzeTestResults;
private getMetricValue;
private evaluateCriteria;
private calculateConfidence;
}
/**
* Utility functions for prompt versioning
*/
/**
* Create a quick A/B test between two prompt templates
*/
export declare function createQuickABTest(name: string, templateA: string, templateB: string, variables?: Record<string, any>, options?: {
description?: string;
trafficSplit?: [number, number];
successCriteria?: ABTestConfig['successCriteria'];
}): {
manager: PromptVersionManager;
testConfig: ABTestConfig;
};
//# sourceMappingURL=prompt-versioning.d.ts.map