@vfarcic/dot-ai
Version:
AI-powered development productivity platform that enhances software development workflows through intelligent automation and AI-driven assistance
100 lines • 3.13 kB
TypeScript
/**
* Embedding Service
*
* Optional semantic search enhancement for pattern matching.
* Gracefully falls back to keyword-only search when embedding providers are not available.
*/
import { CircuitBreakerStats } from './circuit-breaker';
/**
* Supported embedding providers - single source of truth
*/
export declare const EMBEDDING_PROVIDERS: readonly ["openai", "google", "amazon_bedrock"];
export type EmbeddingProviderType = (typeof EMBEDDING_PROVIDERS)[number];
export interface EmbeddingConfig {
provider?: EmbeddingProviderType;
apiKey?: string;
model?: string;
dimensions?: number;
}
export interface EmbeddingProvider {
generateEmbedding(text: string): Promise<number[]>;
generateEmbeddings(texts: string[]): Promise<number[][]>;
isAvailable(): boolean;
getDimensions(): number;
getModel(): string;
}
/**
* Unified Vercel AI SDK Embedding Provider
* Supports OpenAI, Google, and Amazon Bedrock through Vercel AI SDK
*/
export declare class VercelEmbeddingProvider implements EmbeddingProvider {
private providerType;
private apiKey;
private model;
private dimensions;
private available;
private modelInstance;
constructor(config: EmbeddingConfig & {
provider: EmbeddingProviderType;
});
generateEmbedding(text: string): Promise<number[]>;
generateEmbeddings(texts: string[]): Promise<number[][]>;
isAvailable(): boolean;
getDimensions(): number;
getModel(): string;
getProviderType(): string;
}
/**
* Main Embedding Service
* Provides optional semantic search capabilities with graceful degradation
*/
export declare class EmbeddingService {
private provider;
private lastBatchFailureLogTime?;
private suppressedBatchFailureCount;
private static readonly BATCH_FAILURE_LOG_INTERVAL_MS;
constructor(config?: EmbeddingConfig);
/**
* Generate embedding for text
* Throws error if embeddings not available or generation fails
*/
generateEmbedding(text: string): Promise<number[]>;
/**
* Generate embeddings for multiple texts (optional enhancement)
* Returns empty array if embeddings not available
*/
generateEmbeddings(texts: string[]): Promise<number[][]>;
/**
* Check if semantic search is available
*/
isAvailable(): boolean;
/**
* Get embedding dimensions (if available)
*/
getDimensions(): number;
/**
* Get status information for debugging/logging
*/
getStatus(): {
available: boolean;
provider: string | null;
model?: string;
dimensions?: number;
reason?: string;
};
/**
* Create searchable text from pattern data
*/
createPatternSearchText(pattern: {
description: string;
triggers: string[];
suggestedResources: string[];
rationale: string;
}): string;
/**
* Get circuit breaker statistics for monitoring
* Returns null if embedding service is not available
*/
getCircuitBreakerStats(): CircuitBreakerStats | null;
}
//# sourceMappingURL=embedding-service.d.ts.map