toto-agent
Version:
Chatbot agent and reusable components for Toto platform
53 lines (52 loc) • 1.26 kB
TypeScript
export interface CachedResponse {
response: string;
timestamp: number;
context: string;
validation: any;
}
export interface CostMetrics {
totalCalls: number;
totalTokens: number;
estimatedCost: number;
cacheHits: number;
cacheMisses: number;
}
export declare class OnboardingCacheService {
private cache;
private metrics;
private readonly CACHE_TTL;
private readonly COST_PER_1K_TOKENS;
/**
* Generate cache key based on context and user message
*/
private generateCacheKey;
/**
* Get cached response if available and valid
*/
getCachedResponse(context: any, userMessage: string): CachedResponse | null;
/**
* Cache a response
*/
cacheResponse(context: any, userMessage: string, response: string, validation: any): void;
/**
* Track API call metrics
*/
trackApiCall(tokenCount: number): void;
/**
* Get current metrics
*/
getMetrics(): CostMetrics;
/**
* Clear cache
*/
clearCache(): void;
/**
* Get cache size
*/
getCacheSize(): number;
/**
* Clean expired cache entries
*/
cleanExpiredCache(): void;
}
export declare const onboardingCache: OnboardingCacheService;