@lov3kaizen/agentsea-embeddings 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,172 @@
1
+ type ChunkingStrategyType = 'fixed' | 'semantic' | 'recursive' | 'markdown' | 'code' | 'sentence' | 'paragraph' | 'custom';
2
+ interface Chunk {
3
+ id: string;
4
+ text: string;
5
+ index: number;
6
+ startPosition: number;
7
+ endPosition: number;
8
+ tokenCount: number;
9
+ charCount: number;
10
+ overlapPrev: number;
11
+ overlapNext: number;
12
+ metadata: ChunkingMetadata;
13
+ }
14
+ interface ChunkingMetadata {
15
+ documentId?: string;
16
+ source?: string;
17
+ type?: string;
18
+ page?: number;
19
+ section?: string;
20
+ language?: string;
21
+ boundaryType?: string;
22
+ [key: string]: unknown;
23
+ }
24
+ interface ChunkingOptions {
25
+ chunkSize?: number;
26
+ chunkOverlap?: number;
27
+ minChunkSize?: number;
28
+ maxChunkSize?: number;
29
+ tokenCounter?: (text: string) => number;
30
+ documentId?: string;
31
+ source?: string;
32
+ type?: string;
33
+ metadata?: Record<string, unknown>;
34
+ }
35
+ interface FixedChunkingOptions extends ChunkingOptions {
36
+ splitByChars?: boolean;
37
+ separator?: string;
38
+ keepSeparator?: boolean;
39
+ }
40
+ interface SemanticChunkingOptions extends ChunkingOptions {
41
+ similarityThreshold?: number;
42
+ embeddingFn?: (texts: string[]) => Promise<number[][]>;
43
+ breakpointPercentileThreshold?: number;
44
+ bufferSize?: number;
45
+ }
46
+ interface RecursiveChunkingOptions extends ChunkingOptions {
47
+ separators?: string[];
48
+ keepSeparator?: boolean;
49
+ mergeSmallChunks?: boolean;
50
+ }
51
+ interface MarkdownChunkingOptions extends ChunkingOptions {
52
+ preserveHeaders?: boolean;
53
+ includeHeaderHierarchy?: boolean;
54
+ headingLevels?: number[];
55
+ splitCodeBlocks?: boolean;
56
+ preserveLinks?: boolean;
57
+ }
58
+ interface CodeChunkingOptions extends ChunkingOptions {
59
+ language?: string;
60
+ autoDetectLanguage?: boolean;
61
+ splitBy?: 'function' | 'class' | 'module' | 'auto';
62
+ includeComments?: boolean;
63
+ includeImports?: boolean;
64
+ includeTypeDefinitions?: boolean;
65
+ }
66
+ interface SentenceChunkingOptions extends ChunkingOptions {
67
+ combineSentences?: boolean;
68
+ sentenceBoundary?: RegExp;
69
+ minSentences?: number;
70
+ }
71
+ interface ParagraphChunkingOptions extends ChunkingOptions {
72
+ combineParagraphs?: boolean;
73
+ paragraphBoundary?: RegExp;
74
+ minParagraphs?: number;
75
+ }
76
+ interface ChunkingResult {
77
+ chunks: Chunk[];
78
+ totalChunks: number;
79
+ totalTokens: number;
80
+ avgChunkSize: number;
81
+ processingTimeMs: number;
82
+ strategy: ChunkingStrategyType;
83
+ originalLength: number;
84
+ }
85
+ interface ChunkingStats {
86
+ documentsProcessed: number;
87
+ chunksCreated: number;
88
+ tokensProcessed: number;
89
+ avgChunksPerDocument: number;
90
+ avgTokensPerChunk: number;
91
+ strategyDistribution: Record<ChunkingStrategyType, number>;
92
+ }
93
+ interface ChunkingStrategyConfig {
94
+ type: ChunkingStrategyType;
95
+ options: ChunkingOptions;
96
+ description?: string;
97
+ }
98
+ type CustomChunkingFn = (text: string, options: ChunkingOptions) => Promise<Chunk[]> | Chunk[];
99
+ type TokenCounterFn = (text: string) => number;
100
+ type TextSplitterFn = (text: string, separator: string) => string[];
101
+
102
+ declare const defaultTokenCounter: TokenCounterFn;
103
+ declare abstract class BaseChunker {
104
+ abstract readonly strategyType: ChunkingStrategyType;
105
+ protected defaultOptions: ChunkingOptions;
106
+ abstract chunk(text: string, options?: ChunkingOptions): Promise<Chunk[]>;
107
+ protected getOptions(options?: ChunkingOptions): ChunkingOptions & {
108
+ chunkSize: number;
109
+ chunkOverlap: number;
110
+ minChunkSize: number;
111
+ maxChunkSize: number;
112
+ tokenCounter: (text: string) => number;
113
+ metadata: Record<string, unknown>;
114
+ };
115
+ protected createChunk(text: string, index: number, startPosition: number, options: ChunkingOptions, additionalMetadata?: Record<string, unknown>): Chunk;
116
+ protected setOverlapInfo(chunks: Chunk[], overlapChars: number): void;
117
+ protected splitWithOverlap(text: string, chunkSize: number, overlap: number, tokenCounter: TokenCounterFn): string[];
118
+ chunkWithResult(text: string, options?: ChunkingOptions): Promise<ChunkingResult>;
119
+ }
120
+ declare function mergeSmallChunks(chunks: Chunk[], minTokens: number, tokenCounter: TokenCounterFn): Chunk[];
121
+ declare function splitLargeChunks(chunks: Chunk[], maxTokens: number, tokenCounter: TokenCounterFn): Chunk[];
122
+
123
+ declare class FixedChunker extends BaseChunker {
124
+ readonly strategyType: ChunkingStrategyType;
125
+ chunk(text: string, options?: FixedChunkingOptions): Promise<Chunk[]>;
126
+ private getOverlapText;
127
+ }
128
+ declare function createFixedChunker(): FixedChunker;
129
+
130
+ declare class RecursiveChunker extends BaseChunker {
131
+ readonly strategyType: ChunkingStrategyType;
132
+ chunk(text: string, options?: RecursiveChunkingOptions): Promise<Chunk[]>;
133
+ private splitRecursively;
134
+ private splitBySeparator;
135
+ private splitByChars;
136
+ private addOverlap;
137
+ private getEndOverlap;
138
+ }
139
+ declare function createRecursiveChunker(): RecursiveChunker;
140
+
141
+ declare class MarkdownChunker extends BaseChunker {
142
+ readonly strategyType: ChunkingStrategyType;
143
+ chunk(text: string, options?: MarkdownChunkingOptions): Promise<Chunk[]>;
144
+ private parseMarkdown;
145
+ private chunkSection;
146
+ }
147
+ declare function createMarkdownChunker(): MarkdownChunker;
148
+
149
+ declare class CodeChunker extends BaseChunker {
150
+ readonly strategyType: ChunkingStrategyType;
151
+ chunk(text: string, options?: CodeChunkingOptions): Promise<Chunk[]>;
152
+ private detectLanguage;
153
+ private parseCode;
154
+ private splitLargeBlock;
155
+ }
156
+ declare function createCodeChunker(): CodeChunker;
157
+
158
+ declare class SemanticChunker extends BaseChunker {
159
+ readonly strategyType: ChunkingStrategyType;
160
+ chunk(text: string, options?: SemanticChunkingOptions): Promise<Chunk[]>;
161
+ private splitSentences;
162
+ private calculateDistances;
163
+ private findBreakpoints;
164
+ private fallbackChunk;
165
+ private splitLargeChunks;
166
+ }
167
+ declare function createSemanticChunker(): SemanticChunker;
168
+
169
+ declare function createChunker(strategy: ChunkingStrategyType): BaseChunker;
170
+ declare function chunk(text: string, strategy?: ChunkingStrategyType, options?: ChunkingOptions): Promise<Chunk[]>;
171
+
172
+ export { BaseChunker as B, type ChunkingStrategyType as C, FixedChunker as F, MarkdownChunker as M, type ParagraphChunkingOptions as P, RecursiveChunker as R, SemanticChunker as S, type TokenCounterFn as T, type ChunkingOptions as a, type Chunk as b, createFixedChunker as c, defaultTokenCounter as d, createRecursiveChunker as e, createMarkdownChunker as f, CodeChunker as g, createCodeChunker as h, createSemanticChunker as i, createChunker as j, chunk as k, type ChunkingMetadata as l, mergeSmallChunks as m, type FixedChunkingOptions as n, type SemanticChunkingOptions as o, type RecursiveChunkingOptions as p, type MarkdownChunkingOptions as q, type CodeChunkingOptions as r, splitLargeChunks as s, type SentenceChunkingOptions as t, type ChunkingResult as u, type ChunkingStats as v, type ChunkingStrategyConfig as w, type CustomChunkingFn as x, type TextSplitterFn as y };
@@ -0,0 +1,172 @@
1
+ type ChunkingStrategyType = 'fixed' | 'semantic' | 'recursive' | 'markdown' | 'code' | 'sentence' | 'paragraph' | 'custom';
2
+ interface Chunk {
3
+ id: string;
4
+ text: string;
5
+ index: number;
6
+ startPosition: number;
7
+ endPosition: number;
8
+ tokenCount: number;
9
+ charCount: number;
10
+ overlapPrev: number;
11
+ overlapNext: number;
12
+ metadata: ChunkingMetadata;
13
+ }
14
+ interface ChunkingMetadata {
15
+ documentId?: string;
16
+ source?: string;
17
+ type?: string;
18
+ page?: number;
19
+ section?: string;
20
+ language?: string;
21
+ boundaryType?: string;
22
+ [key: string]: unknown;
23
+ }
24
+ interface ChunkingOptions {
25
+ chunkSize?: number;
26
+ chunkOverlap?: number;
27
+ minChunkSize?: number;
28
+ maxChunkSize?: number;
29
+ tokenCounter?: (text: string) => number;
30
+ documentId?: string;
31
+ source?: string;
32
+ type?: string;
33
+ metadata?: Record<string, unknown>;
34
+ }
35
+ interface FixedChunkingOptions extends ChunkingOptions {
36
+ splitByChars?: boolean;
37
+ separator?: string;
38
+ keepSeparator?: boolean;
39
+ }
40
+ interface SemanticChunkingOptions extends ChunkingOptions {
41
+ similarityThreshold?: number;
42
+ embeddingFn?: (texts: string[]) => Promise<number[][]>;
43
+ breakpointPercentileThreshold?: number;
44
+ bufferSize?: number;
45
+ }
46
+ interface RecursiveChunkingOptions extends ChunkingOptions {
47
+ separators?: string[];
48
+ keepSeparator?: boolean;
49
+ mergeSmallChunks?: boolean;
50
+ }
51
+ interface MarkdownChunkingOptions extends ChunkingOptions {
52
+ preserveHeaders?: boolean;
53
+ includeHeaderHierarchy?: boolean;
54
+ headingLevels?: number[];
55
+ splitCodeBlocks?: boolean;
56
+ preserveLinks?: boolean;
57
+ }
58
+ interface CodeChunkingOptions extends ChunkingOptions {
59
+ language?: string;
60
+ autoDetectLanguage?: boolean;
61
+ splitBy?: 'function' | 'class' | 'module' | 'auto';
62
+ includeComments?: boolean;
63
+ includeImports?: boolean;
64
+ includeTypeDefinitions?: boolean;
65
+ }
66
+ interface SentenceChunkingOptions extends ChunkingOptions {
67
+ combineSentences?: boolean;
68
+ sentenceBoundary?: RegExp;
69
+ minSentences?: number;
70
+ }
71
+ interface ParagraphChunkingOptions extends ChunkingOptions {
72
+ combineParagraphs?: boolean;
73
+ paragraphBoundary?: RegExp;
74
+ minParagraphs?: number;
75
+ }
76
+ interface ChunkingResult {
77
+ chunks: Chunk[];
78
+ totalChunks: number;
79
+ totalTokens: number;
80
+ avgChunkSize: number;
81
+ processingTimeMs: number;
82
+ strategy: ChunkingStrategyType;
83
+ originalLength: number;
84
+ }
85
+ interface ChunkingStats {
86
+ documentsProcessed: number;
87
+ chunksCreated: number;
88
+ tokensProcessed: number;
89
+ avgChunksPerDocument: number;
90
+ avgTokensPerChunk: number;
91
+ strategyDistribution: Record<ChunkingStrategyType, number>;
92
+ }
93
+ interface ChunkingStrategyConfig {
94
+ type: ChunkingStrategyType;
95
+ options: ChunkingOptions;
96
+ description?: string;
97
+ }
98
+ type CustomChunkingFn = (text: string, options: ChunkingOptions) => Promise<Chunk[]> | Chunk[];
99
+ type TokenCounterFn = (text: string) => number;
100
+ type TextSplitterFn = (text: string, separator: string) => string[];
101
+
102
+ declare const defaultTokenCounter: TokenCounterFn;
103
+ declare abstract class BaseChunker {
104
+ abstract readonly strategyType: ChunkingStrategyType;
105
+ protected defaultOptions: ChunkingOptions;
106
+ abstract chunk(text: string, options?: ChunkingOptions): Promise<Chunk[]>;
107
+ protected getOptions(options?: ChunkingOptions): ChunkingOptions & {
108
+ chunkSize: number;
109
+ chunkOverlap: number;
110
+ minChunkSize: number;
111
+ maxChunkSize: number;
112
+ tokenCounter: (text: string) => number;
113
+ metadata: Record<string, unknown>;
114
+ };
115
+ protected createChunk(text: string, index: number, startPosition: number, options: ChunkingOptions, additionalMetadata?: Record<string, unknown>): Chunk;
116
+ protected setOverlapInfo(chunks: Chunk[], overlapChars: number): void;
117
+ protected splitWithOverlap(text: string, chunkSize: number, overlap: number, tokenCounter: TokenCounterFn): string[];
118
+ chunkWithResult(text: string, options?: ChunkingOptions): Promise<ChunkingResult>;
119
+ }
120
+ declare function mergeSmallChunks(chunks: Chunk[], minTokens: number, tokenCounter: TokenCounterFn): Chunk[];
121
+ declare function splitLargeChunks(chunks: Chunk[], maxTokens: number, tokenCounter: TokenCounterFn): Chunk[];
122
+
123
+ declare class FixedChunker extends BaseChunker {
124
+ readonly strategyType: ChunkingStrategyType;
125
+ chunk(text: string, options?: FixedChunkingOptions): Promise<Chunk[]>;
126
+ private getOverlapText;
127
+ }
128
+ declare function createFixedChunker(): FixedChunker;
129
+
130
+ declare class RecursiveChunker extends BaseChunker {
131
+ readonly strategyType: ChunkingStrategyType;
132
+ chunk(text: string, options?: RecursiveChunkingOptions): Promise<Chunk[]>;
133
+ private splitRecursively;
134
+ private splitBySeparator;
135
+ private splitByChars;
136
+ private addOverlap;
137
+ private getEndOverlap;
138
+ }
139
+ declare function createRecursiveChunker(): RecursiveChunker;
140
+
141
+ declare class MarkdownChunker extends BaseChunker {
142
+ readonly strategyType: ChunkingStrategyType;
143
+ chunk(text: string, options?: MarkdownChunkingOptions): Promise<Chunk[]>;
144
+ private parseMarkdown;
145
+ private chunkSection;
146
+ }
147
+ declare function createMarkdownChunker(): MarkdownChunker;
148
+
149
+ declare class CodeChunker extends BaseChunker {
150
+ readonly strategyType: ChunkingStrategyType;
151
+ chunk(text: string, options?: CodeChunkingOptions): Promise<Chunk[]>;
152
+ private detectLanguage;
153
+ private parseCode;
154
+ private splitLargeBlock;
155
+ }
156
+ declare function createCodeChunker(): CodeChunker;
157
+
158
+ declare class SemanticChunker extends BaseChunker {
159
+ readonly strategyType: ChunkingStrategyType;
160
+ chunk(text: string, options?: SemanticChunkingOptions): Promise<Chunk[]>;
161
+ private splitSentences;
162
+ private calculateDistances;
163
+ private findBreakpoints;
164
+ private fallbackChunk;
165
+ private splitLargeChunks;
166
+ }
167
+ declare function createSemanticChunker(): SemanticChunker;
168
+
169
+ declare function createChunker(strategy: ChunkingStrategyType): BaseChunker;
170
+ declare function chunk(text: string, strategy?: ChunkingStrategyType, options?: ChunkingOptions): Promise<Chunk[]>;
171
+
172
+ export { BaseChunker as B, type ChunkingStrategyType as C, FixedChunker as F, MarkdownChunker as M, type ParagraphChunkingOptions as P, RecursiveChunker as R, SemanticChunker as S, type TokenCounterFn as T, type ChunkingOptions as a, type Chunk as b, createFixedChunker as c, defaultTokenCounter as d, createRecursiveChunker as e, createMarkdownChunker as f, CodeChunker as g, createCodeChunker as h, createSemanticChunker as i, createChunker as j, chunk as k, type ChunkingMetadata as l, mergeSmallChunks as m, type FixedChunkingOptions as n, type SemanticChunkingOptions as o, type RecursiveChunkingOptions as p, type MarkdownChunkingOptions as q, type CodeChunkingOptions as r, splitLargeChunks as s, type SentenceChunkingOptions as t, type ChunkingResult as u, type ChunkingStats as v, type ChunkingStrategyConfig as w, type CustomChunkingFn as x, type TextSplitterFn as y };
@@ -0,0 +1,297 @@
1
+ import { E as EmbeddingVector, a as EmbeddingResult, c as BatchEmbeddingResult, g as EmbeddingModelInfo, b as EmbeddingOptions, B as BatchEmbeddingOptions } from './embedding.types-CCgPVxt1.js';
2
+
3
+ type EmbeddingProviderType = 'openai' | 'cohere' | 'voyage' | 'local' | 'huggingface' | 'anthropic' | 'google' | 'custom';
4
+ interface ProviderConfig {
5
+ type: EmbeddingProviderType;
6
+ apiKey?: string;
7
+ baseUrl?: string;
8
+ model?: string;
9
+ timeout?: number;
10
+ maxRetries?: number;
11
+ retryDelay?: number;
12
+ headers?: Record<string, string>;
13
+ options?: Record<string, unknown>;
14
+ }
15
+ interface OpenAIProviderConfig extends ProviderConfig {
16
+ type: 'openai';
17
+ organization?: string;
18
+ apiVersion?: string;
19
+ model?: string;
20
+ encodingFormat?: 'float' | 'base64';
21
+ dimensions?: number;
22
+ }
23
+ interface CohereProviderConfig extends ProviderConfig {
24
+ type: 'cohere';
25
+ model?: string;
26
+ inputType?: 'search_document' | 'search_query' | 'classification' | 'clustering';
27
+ truncate?: 'NONE' | 'START' | 'END';
28
+ }
29
+ interface VoyageProviderConfig extends ProviderConfig {
30
+ type: 'voyage';
31
+ model?: string;
32
+ inputType?: 'document' | 'query';
33
+ truncation?: boolean;
34
+ }
35
+ interface LocalProviderConfig extends ProviderConfig {
36
+ type: 'local';
37
+ modelPath?: string;
38
+ modelType?: 'onnx' | 'transformers' | 'sentence-transformers';
39
+ device?: 'cpu' | 'cuda' | 'mps';
40
+ batchSize?: number;
41
+ normalize?: boolean;
42
+ pooling?: 'mean' | 'cls' | 'max';
43
+ }
44
+ interface HuggingFaceProviderConfig extends ProviderConfig {
45
+ type: 'huggingface';
46
+ model?: string;
47
+ useInferenceApi?: boolean;
48
+ waitForModel?: boolean;
49
+ }
50
+ interface EmbeddingRequest {
51
+ text: string;
52
+ model?: string;
53
+ user?: string;
54
+ options?: Record<string, unknown>;
55
+ }
56
+ interface BatchEmbeddingRequest {
57
+ texts: string[];
58
+ model?: string;
59
+ user?: string;
60
+ options?: Record<string, unknown>;
61
+ }
62
+ interface ProviderResponse {
63
+ embeddings: EmbeddingVector[];
64
+ model: string;
65
+ usage: TokenUsage;
66
+ metadata?: Record<string, unknown>;
67
+ }
68
+ interface TokenUsage {
69
+ promptTokens: number;
70
+ totalTokens: number;
71
+ }
72
+ interface ProviderError {
73
+ code: string;
74
+ message: string;
75
+ status?: number;
76
+ retryable: boolean;
77
+ retryAfter?: number;
78
+ details?: Record<string, unknown>;
79
+ }
80
+ interface ProviderHealth {
81
+ healthy: boolean;
82
+ latencyMs: number;
83
+ lastCheck: number;
84
+ error?: string;
85
+ rateLimit?: RateLimitInfo;
86
+ }
87
+ interface RateLimitInfo {
88
+ remaining: number;
89
+ limit: number;
90
+ reset: number;
91
+ retryAfter?: number;
92
+ }
93
+ interface ProviderMetrics {
94
+ provider: EmbeddingProviderType;
95
+ totalRequests: number;
96
+ successfulRequests: number;
97
+ failedRequests: number;
98
+ totalTokens: number;
99
+ avgLatencyMs: number;
100
+ p50LatencyMs: number;
101
+ p95LatencyMs: number;
102
+ p99LatencyMs: number;
103
+ errorRate: number;
104
+ rateLimitHits: number;
105
+ estimatedCostUSD: number;
106
+ }
107
+ interface ModelInfo {
108
+ id: string;
109
+ name: string;
110
+ provider: EmbeddingProviderType;
111
+ dimensions: number;
112
+ maxTokens: number;
113
+ maxBatchSize: number;
114
+ costPer1K?: number;
115
+ description?: string;
116
+ releaseDate?: string;
117
+ deprecated?: boolean;
118
+ replacement?: string;
119
+ }
120
+ interface ProviderCapabilities {
121
+ batch: boolean;
122
+ maxBatchSize: number;
123
+ streaming: boolean;
124
+ customDimensions: boolean;
125
+ inputTypes: string[];
126
+ models: string[];
127
+ }
128
+ interface ProviderFactoryOptions {
129
+ defaultProvider?: EmbeddingProviderType;
130
+ providers?: Record<EmbeddingProviderType, ProviderConfig>;
131
+ enableMetrics?: boolean;
132
+ enableHealthChecks?: boolean;
133
+ healthCheckInterval?: number;
134
+ }
135
+ interface CustomProviderConfig extends ProviderConfig {
136
+ type: 'custom';
137
+ embedFn: (text: string, options?: Record<string, unknown>) => Promise<EmbeddingResult>;
138
+ batchEmbedFn?: (texts: string[], options?: Record<string, unknown>) => Promise<BatchEmbeddingResult>;
139
+ modelInfo: ModelInfo;
140
+ }
141
+
142
+ declare abstract class EmbeddingModel {
143
+ abstract readonly info: EmbeddingModelInfo;
144
+ abstract embed(text: string, options?: EmbeddingOptions): Promise<EmbeddingResult>;
145
+ abstract embedBatch(texts: string[], options?: BatchEmbeddingOptions): Promise<BatchEmbeddingResult>;
146
+ get dimensions(): number;
147
+ get maxTokens(): number;
148
+ get maxBatchSize(): number;
149
+ get name(): string;
150
+ get provider(): string;
151
+ countTokens(text: string): number;
152
+ exceedsMaxTokens(text: string): boolean;
153
+ truncateToMaxTokens(text: string): string;
154
+ static cosineSimilarity(a: EmbeddingVector, b: EmbeddingVector): number;
155
+ static euclideanDistance(a: EmbeddingVector, b: EmbeddingVector): number;
156
+ static dotProduct(a: EmbeddingVector, b: EmbeddingVector): number;
157
+ static normalize(vector: EmbeddingVector): EmbeddingVector;
158
+ static average(vectors: EmbeddingVector[]): EmbeddingVector;
159
+ static weightedAverage(vectors: EmbeddingVector[], weights: number[]): EmbeddingVector;
160
+ }
161
+ declare class ModelRegistry {
162
+ private models;
163
+ private defaultModel;
164
+ register(model: EmbeddingModel, isDefault?: boolean): void;
165
+ get(provider: string, name: string): EmbeddingModel | undefined;
166
+ getByKey(key: string): EmbeddingModel | undefined;
167
+ getDefault(): EmbeddingModel | undefined;
168
+ setDefault(provider: string, name: string): void;
169
+ list(): EmbeddingModelInfo[];
170
+ has(provider: string, name: string): boolean;
171
+ remove(provider: string, name: string): boolean;
172
+ clear(): void;
173
+ }
174
+ declare const modelRegistry: ModelRegistry;
175
+
176
+ declare abstract class BaseProvider extends EmbeddingModel {
177
+ protected config: ProviderConfig;
178
+ protected metrics: ProviderMetrics;
179
+ protected health: ProviderHealth;
180
+ protected latencies: number[];
181
+ private readonly maxLatencySamples;
182
+ constructor(config: ProviderConfig);
183
+ private createInitialMetrics;
184
+ protected abstract doEmbed(texts: string[], options?: EmbeddingOptions): Promise<{
185
+ vectors: number[][];
186
+ tokenCount: number;
187
+ }>;
188
+ embed(text: string, options?: EmbeddingOptions): Promise<EmbeddingResult>;
189
+ embedBatch(texts: string[], options?: BatchEmbeddingOptions): Promise<BatchEmbeddingResult>;
190
+ protected isRetryable(error: Error): boolean;
191
+ protected recordLatency(latencyMs: number): void;
192
+ protected calculatePercentile(p: number): number;
193
+ protected updateMetrics(): void;
194
+ getMetrics(): ProviderMetrics;
195
+ getHealth(): ProviderHealth;
196
+ checkHealth(): Promise<ProviderHealth>;
197
+ resetMetrics(): void;
198
+ }
199
+
200
+ declare class OpenAIProvider extends BaseProvider {
201
+ private modelInfo;
202
+ private apiKey;
203
+ private baseUrl;
204
+ private organization?;
205
+ constructor(config: OpenAIProviderConfig);
206
+ get info(): EmbeddingModelInfo;
207
+ protected doEmbed(texts: string[], options?: EmbeddingOptions): Promise<{
208
+ vectors: number[][];
209
+ tokenCount: number;
210
+ }>;
211
+ countTokens(text: string): number;
212
+ }
213
+ declare function createOpenAIProvider(config: OpenAIProviderConfig): OpenAIProvider;
214
+
215
+ declare class CohereProvider extends BaseProvider {
216
+ private modelInfo;
217
+ private apiKey;
218
+ private baseUrl;
219
+ private inputType;
220
+ private truncate;
221
+ constructor(config: CohereProviderConfig);
222
+ get info(): EmbeddingModelInfo;
223
+ protected doEmbed(texts: string[], options?: EmbeddingOptions): Promise<{
224
+ vectors: number[][];
225
+ tokenCount: number;
226
+ }>;
227
+ setInputType(inputType: CohereProviderConfig['inputType']): this;
228
+ countTokens(text: string): number;
229
+ }
230
+ declare function createCohereProvider(config: CohereProviderConfig): CohereProvider;
231
+
232
+ declare class VoyageProvider extends BaseProvider {
233
+ private modelInfo;
234
+ private apiKey;
235
+ private baseUrl;
236
+ private inputType;
237
+ private truncation;
238
+ constructor(config: VoyageProviderConfig);
239
+ get info(): EmbeddingModelInfo;
240
+ protected doEmbed(texts: string[], options?: EmbeddingOptions): Promise<{
241
+ vectors: number[][];
242
+ tokenCount: number;
243
+ }>;
244
+ setInputType(inputType: VoyageProviderConfig['inputType']): this;
245
+ countTokens(text: string): number;
246
+ }
247
+ declare function createVoyageProvider(config: VoyageProviderConfig): VoyageProvider;
248
+
249
+ type LocalEmbeddingFn = (texts: string[], options?: Record<string, unknown>) => Promise<number[][]>;
250
+ interface LocalProviderOptions extends LocalProviderConfig {
251
+ embedFn?: LocalEmbeddingFn;
252
+ dimensions: number;
253
+ name?: string;
254
+ maxTokens?: number;
255
+ maxBatchSize?: number;
256
+ }
257
+ declare class LocalProvider extends BaseProvider {
258
+ private modelInfo;
259
+ private embedFn;
260
+ private normalize;
261
+ private batchSize;
262
+ constructor(config: LocalProviderOptions);
263
+ get info(): EmbeddingModelInfo;
264
+ protected doEmbed(texts: string[], options?: EmbeddingOptions): Promise<{
265
+ vectors: number[][];
266
+ tokenCount: number;
267
+ }>;
268
+ setEmbedFunction(fn: LocalEmbeddingFn): this;
269
+ countTokens(text: string): number;
270
+ }
271
+ declare function createLocalProvider(config: LocalProviderOptions): LocalProvider;
272
+ declare function createMockProvider(config: {
273
+ dimensions: number;
274
+ name?: string;
275
+ delay?: number;
276
+ }): LocalProvider;
277
+ declare function createRandomProvider(config: {
278
+ dimensions: number;
279
+ name?: string;
280
+ }): LocalProvider;
281
+
282
+ declare class HuggingFaceProvider extends BaseProvider {
283
+ private modelInfo;
284
+ private apiKey;
285
+ private baseUrl;
286
+ private waitForModel;
287
+ constructor(config: HuggingFaceProviderConfig);
288
+ get info(): EmbeddingModelInfo;
289
+ protected doEmbed(texts: string[], _options?: EmbeddingOptions): Promise<{
290
+ vectors: number[][];
291
+ tokenCount: number;
292
+ }>;
293
+ countTokens(text: string): number;
294
+ }
295
+ declare function createHuggingFaceProvider(config: HuggingFaceProviderConfig): HuggingFaceProvider;
296
+
297
+ export { BaseProvider as B, CohereProvider as C, type EmbeddingProviderType as E, HuggingFaceProvider as H, LocalProvider as L, type ModelInfo as M, OpenAIProvider as O, type ProviderConfig as P, type RateLimitInfo as R, type TokenUsage as T, VoyageProvider as V, EmbeddingModel as a, ModelRegistry as b, createOpenAIProvider as c, createCohereProvider as d, createVoyageProvider as e, createLocalProvider as f, createMockProvider as g, createRandomProvider as h, createHuggingFaceProvider as i, type LocalEmbeddingFn as j, type LocalProviderOptions as k, type OpenAIProviderConfig as l, modelRegistry as m, type CohereProviderConfig as n, type VoyageProviderConfig as o, type LocalProviderConfig as p, type HuggingFaceProviderConfig as q, type EmbeddingRequest as r, type BatchEmbeddingRequest as s, type ProviderResponse as t, type ProviderError as u, type ProviderHealth as v, type ProviderMetrics as w, type ProviderCapabilities as x, type ProviderFactoryOptions as y, type CustomProviderConfig as z };