/** * Embedding Provider Types * * Interfaces for embedding generation providers. */ /** * Supported embedding providers */ export type EmbeddingProvider = 'openai' | 'anthropic' | 'cohere' | 'huggingface' | 'voyage' | 'jina' | 'local' | 'custom'; /** * Embedding model configuration */ export interface IEmbeddingModelConfig { /** Provider name */ provider: EmbeddingProvider; /** Model identifier */ model: string; /** API key (can be pulled from secrets) */ apiKey?: string; /** API base URL */ baseUrl?: string; /** Output dimensions (for models that support it) */ dimensions?: number; /** Request timeout in ms */ timeout?: number; /** Batch size for batch embedding */ batchSize?: number; /** Custom headers */ headers?: Record; } /** * Embedding request options */ export interface IEmbedOptions { /** Input type hint (for providers that support it) */ inputType?: 'search_document' | 'search_query' | 'classification' | 'clustering'; /** Truncation strategy */ truncation?: boolean | 'start' | 'end'; /** Custom parameters */ params?: Record; } /** * Embedding result for a single text */ export interface IEmbeddingResult { /** Text that was embedded */ text: string; /** Embedding vector */ embedding: number[]; /** Token count (if available) */ tokenCount?: number; } /** * Batch embedding result */ export interface IBatchEmbeddingResult { /** Embeddings */ embeddings: IEmbeddingResult[]; /** Total tokens used */ totalTokens?: number; /** Model used */ model: string; /** Provider used */ provider: EmbeddingProvider; } /** * Embedding provider interface */ export interface IEmbeddingProvider { /** Provider name */ readonly provider: EmbeddingProvider; /** Model name */ readonly model: string; /** Output dimensions */ readonly dimensions: number; /** Generate embedding for single text */ embed(text: string, options?: IEmbedOptions): Promise; /** Generate embeddings for multiple texts */ embedBatch(texts: string[], options?: IEmbedOptions): Promise; /** Get token count for text (if supported) */ countTokens?(text: string): Promise; } /** * OpenAI embedding config */ export interface IOpenAIEmbeddingConfig extends IEmbeddingModelConfig { provider: 'openai'; /** Model: text-embedding-ada-002, text-embedding-3-small, text-embedding-3-large */ model: string; /** Encoding format */ encodingFormat?: 'float' | 'base64'; } /** * Cohere embedding config */ export interface ICohereEmbeddingConfig extends IEmbeddingModelConfig { provider: 'cohere'; /** Model: embed-english-v3.0, embed-multilingual-v3.0, etc. */ model: string; /** Input type */ inputType?: 'search_document' | 'search_query' | 'classification' | 'clustering'; /** Truncation */ truncate?: 'NONE' | 'START' | 'END'; } /** * Voyage AI embedding config */ export interface IVoyageEmbeddingConfig extends IEmbeddingModelConfig { provider: 'voyage'; /** Model: voyage-large-2, voyage-code-2, etc. */ model: string; /** Input type */ inputType?: 'document' | 'query'; } /** * Jina embedding config */ export interface IJinaEmbeddingConfig extends IEmbeddingModelConfig { provider: 'jina'; /** Model: jina-embeddings-v2-base-en, jina-embeddings-v2-small-en, etc. */ model: string; } /** * HuggingFace embedding config */ export interface IHuggingFaceEmbeddingConfig extends IEmbeddingModelConfig { provider: 'huggingface'; /** Model ID or URL */ model: string; /** Use HuggingFace Inference API */ useInferenceAPI?: boolean; } /** * Local embedding config (for self-hosted models) */ export interface ILocalEmbeddingConfig extends IEmbeddingModelConfig { provider: 'local'; /** Model path or identifier */ model: string; /** Device to use (cpu, cuda, mps) */ device?: string; /** Pooling strategy */ pooling?: 'mean' | 'cls' | 'max'; }