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
32 lines • 912 B
TypeScript
/**
* Common types for ai-patterns
*/
/**
* Async function type
*/
export type AsyncFunction<TResult = any, TArgs extends any[] = any[]> = (...args: TArgs) => Promise<TResult>;
/**
* Value that may or may not be a promise
*/
export type MaybePromise<T> = T | Promise<T>;
/**
* Base pattern interface
*/
export interface Pattern<TOptions = any, TResult = any> {
execute: (...args: any[]) => Promise<TResult>;
options: TOptions;
}
/**
* Logger interface for pattern logging
*/
export interface Logger {
info(message: string, meta?: Record<string, unknown>): void;
warn(message: string, meta?: Record<string, unknown>): void;
error(message: string, meta?: Record<string, unknown>): void;
debug(message: string, meta?: Record<string, unknown>): void;
}
/**
* Default console logger implementation
*/
export declare const defaultLogger: Logger;
//# sourceMappingURL=common.d.ts.map