@vfarcic/dot-ai
Version:
AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance
111 lines • 3.31 kB
TypeScript
/**
* Base Vector Service
*
* Generic vector operations that can be extended for different data types
* (patterns, capabilities, dependencies, etc.)
*
* PRD #359: Now calls plugin directly instead of going through VectorDBService.
*/
import { EmbeddingService } from './embedding-service';
export interface BaseSearchOptions {
limit?: number;
scoreThreshold?: number;
keywordWeight?: number;
filter?: Record<string, unknown>;
}
export interface BaseSearchResult<T> {
data: T;
score: number;
matchType: 'keyword' | 'semantic' | 'hybrid';
}
export interface SearchMode {
semantic: boolean;
provider?: string;
reason?: string;
}
/**
* Document stored in vector database
*/
export interface VectorDocument {
id: string;
payload: Record<string, unknown>;
vector?: number[];
}
/**
* Abstract base class for vector-based data services
*/
export declare abstract class BaseVectorService<T> {
protected embeddingService: EmbeddingService;
protected collectionName: string;
constructor(collectionName: string, embeddingService?: EmbeddingService);
/**
* Invoke a plugin tool and extract the result
* @throws Error if plugin returns an error response
*/
private invokePlugin;
/**
* Initialize the collection
*/
initialize(): Promise<void>;
/**
* Check if collection exists without creating it
*/
collectionExists(): Promise<boolean>;
/**
* Health check for Vector DB connection
*/
healthCheck(): Promise<boolean>;
/**
* Store data in Vector DB with semantic embedding
*/
storeData(data: T): Promise<void>;
/**
* Search for data using hybrid semantic + keyword matching
*/
searchData(query: string, options?: BaseSearchOptions): Promise<BaseSearchResult<T>[]>;
/**
* Get data by ID
*/
getData(id: string): Promise<T | null>;
/**
* Delete data by ID
*/
deleteData(id: string): Promise<void>;
/**
* Delete all data (preserves collection structure)
*/
deleteAllData(): Promise<void>;
/**
* Query data with Qdrant filter (no semantic search)
* @param filter - Qdrant filter object constructed by AI
* @param limit - Maximum results to return
*/
queryWithFilter(filter: Record<string, unknown>, limit?: number): Promise<T[]>;
/**
* Get all data (limited)
*/
getAllData(limit?: number): Promise<T[]>;
/**
* Get total count of data items
*/
getDataCount(): Promise<number>;
/**
* Get current search mode (semantic vs keyword-only)
*/
getSearchMode(): SearchMode;
protected abstract createSearchText(data: T): string;
protected abstract extractId(data: T): string;
protected abstract createPayload(data: T): Record<string, unknown>;
protected abstract payloadToData(payload: Record<string, unknown>): T;
protected extractKeywords(query: string): string[];
/**
* Hybrid search combining semantic and keyword matching
*/
private hybridSearch;
/**
* Combine semantic and keyword results with hybrid ranking
* Keyword matches are prioritized for exact term matches
*/
private combineHybridResults;
}
//# sourceMappingURL=base-vector-service.d.ts.map