ai-patterns
Version:
Production-ready TypeScript patterns to build solid and robust AI applications. Retry logic, circuit breakers, rate limiting, human-in-the-loop escalation, prompt versioning, response validation, context window management, and more—all with complete type
18 lines • 729 B
TypeScript
/**
* Memoize Pattern - Cache function results
*/
import { Logger } from "../types/common";
export interface MemoizeOptions<TArgs extends any[] = any[], TResult = any> {
execute: (...args: TArgs) => Promise<TResult> | TResult;
ttl?: number;
keyFn?: (...args: TArgs) => string;
logger?: Logger;
onCacheHit?: (key: string) => void;
onCacheMiss?: (key: string) => void;
}
export interface MemoizedFunction<TArgs extends any[] = any[], TResult = any> {
(...args: TArgs): Promise<TResult>;
clear: () => void;
}
export declare function memoize<TArgs extends any[] = any[], TResult = any>(options: MemoizeOptions<TArgs, TResult>): MemoizedFunction<TArgs, TResult>;
//# sourceMappingURL=memoize.d.ts.map