pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
56 lines (55 loc) • 1.55 kB
TypeScript
import { CacheParams } from '../helpers/query-cache';
/**
* Search query cache using vector similarity
*/
export declare function searchQueryCache({ query, area, region, country, timeline, lat, lng, radius, limit }: {
query: string;
area: string;
region?: string;
country?: string;
timeline?: string;
lat?: number;
lng?: number;
radius?: number;
limit?: number;
}): Promise<any[]>;
export declare class SupabaseQueryCache {
private openai;
constructor();
/**
* Get cached result using vector similarity search
*/
getCachedResult(prompt: string, location: CacheParams): Promise<any | null>;
/**
* Set cached result with vector embedding
*/
setCachedResult(prompt: string, location: CacheParams, result: any): Promise<void>;
/**
* Batch insert multiple cache entries for better performance
*/
batchSetCachedResults(entries: Array<{
prompt: string;
location: CacheParams;
result: any;
}>): Promise<void>;
/**
* Search cache by location filters without prompt similarity
*/
searchByLocation(location: CacheParams, limit?: number): Promise<any[]>;
/**
* Clean up expired cache entries
*/
cleanupExpired(): Promise<number>;
/**
* Get cache statistics
*/
getStats(): Promise<{
totalEntries: number;
expiredEntries: number;
byArea: Record<string, number>;
}>;
/**
* Hash function for generating consistent IDs
*/
private hashString;
}