@codai/memorai-core
Version:
Simplified advanced memory engine - no tiers, just powerful semantic search with persistence
83 lines • 2.66 kB
TypeScript
/**
* Optimized Qdrant Configuration for Enterprise Performance
* Addresses the 45GB memory issue and slow performance
*/
import type { MemoryQuery } from '../types/index.js';
import type { SearchResult, VectorPoint, VectorStore } from './VectorStore.js';
export interface QdrantSearchPoint {
id: string | number;
version: number;
score: number;
payload?: Record<string, unknown> | {
[key: string]: unknown;
} | null;
vector?: Record<string, unknown> | number[] | {
[key: string]: number[];
} | null;
shard_key?: string | number | Record<string, unknown> | null;
}
export interface QdrantFilter {
must: QdrantFilterCondition[];
}
export interface QdrantFilterCondition {
key: string;
match: {
value: string | number | boolean;
};
}
export interface OptimizedQdrantConfig {
url: string;
collection: string;
dimension: number;
apiKey?: string;
batchSize: number;
maxRetries: number;
requestTimeout: number;
connectionPoolSize: number;
enableCompression: boolean;
quantizationEnabled: boolean;
segmentThreshold: number;
hnswM: number;
hnswEfConstruct: number;
fullScanThreshold: number;
}
export declare class OptimizedQdrantVectorStore implements VectorStore {
private client;
private collection;
private dimension;
private config;
private connectionPool;
private currentConnectionIndex;
constructor(config: OptimizedQdrantConfig);
private initializeConnectionPool;
private getConnection;
initialize(): Promise<void>;
private createOptimizedCollection;
private updateCollectionConfig;
private createOptimizedIndexes;
upsert(points: VectorPoint[]): Promise<void>;
private upsertBatch;
search(vector: number[], query: MemoryQuery): Promise<SearchResult[]>;
delete(ids: string[]): Promise<void>;
private deleteBatch;
count(tenantId: string): Promise<number>;
healthCheck(): Promise<boolean>;
checkDuplicateByHash(contentHash: string, tenantId: string, agentId?: string): Promise<string | null>;
updateMemoryAccess(memoryId: string): Promise<void>;
getMemoryStats(tenantId: string): Promise<{
totalMemories: number;
averageAccessCount: number;
oldestMemory: string | null;
newestMemory: string | null;
duplicateCount: number;
}>;
/**
* Optimize collection for better performance
*/
optimizeCollection(): Promise<void>;
private buildFilter;
private chunkArray;
private retryOperation;
close(): Promise<void>;
}
//# sourceMappingURL=OptimizedQdrantVectorStore.d.ts.map