pulse-ai-utils
Version:
Utility functions and helpers for AI-powered applications
79 lines (78 loc) • 2.22 kB
TypeScript
export interface VectorSearchOptions {
query: string;
embedding?: number[];
limit?: number;
threshold?: number;
lat?: number;
lng?: number;
radius?: number;
filters?: {
type?: string;
source?: string;
area?: string;
region?: string;
dateFrom?: string;
dateTo?: string;
seen?: boolean;
};
}
export interface ContentSearchResult {
id: string;
type: string;
title: string;
source: string | null;
source_url: string | null;
image_url: string | null;
data: any;
seen: boolean;
rank: number | null;
content_date: string | null;
similarity: number;
distance_km?: number;
total_similarity?: number;
content_similarity?: number;
location_similarity?: number;
temporal_similarity?: number;
query_type?: string;
geohash_matched?: boolean;
semantic_score?: number;
}
export interface ChunkSearchResult {
content_id: string;
chunk_id: string;
chunk_index: number;
chunk_text: string;
metadata: any;
similarity: number;
}
/**
* Search content using vector similarity with optional geographic filtering
*/
export declare function searchContent(options: VectorSearchOptions): Promise<ContentSearchResult[]>;
/**
* Search content chunks for longer documents
*/
export declare function searchContentChunks(query: string, limit?: number, threshold?: number): Promise<ChunkSearchResult[]>;
/**
* Hybrid search combining vector and full-text search with optional geographic filtering
*/
export declare function hybridSearch(query: string, options?: {
vectorWeight?: number;
textWeight?: number;
limit?: number;
lat?: number;
lng?: number;
radius?: number;
filters?: VectorSearchOptions['filters'];
}): Promise<ContentSearchResult[]>;
/**
* Get similar content based on an existing content ID
*/
export declare function findSimilarContent(contentId: string, limit?: number): Promise<ContentSearchResult[]>;
/**
* Update content metadata (seen, rank) after user interaction
*/
export declare function updateContentMetadata(contentId: string, updates: {
seen?: boolean;
rank?: number;
}): Promise<void>;