UNPKG

crewai-ts

Version:

TypeScript port of crewAI for agent-based workflows

142 lines 3.41 kB
/** * FastEmbedder Implementation * * Lightweight, efficient local embeddings using fastembed * Optimized for performance and low resource usage */ import { BaseEmbedder, BaseEmbedderOptions } from './BaseEmbedder.js'; /** * FastEmbedder Options */ export interface FastEmbedderOptions extends BaseEmbedderOptions { /** * Model name */ model: string; /** * Model path */ modelPath: string; /** * Dimensions of the embeddings */ dimensions: number; /** * Maximum sequence length */ maxLength?: number; /** * Whether to use average pooling */ useAveragePooling?: boolean; /** * Request timeout in milliseconds */ timeout?: number; /** * Path to the model cache directory * @default 'node_modules/.cache/fastembed' */ cacheDir?: string; /** * Use multilingual model * @default false */ multilingual?: boolean; /** * Whether to batch inputs internally * @default true */ useBatching?: boolean; /** * Internal batch size for processing * @default 32 */ internalBatchSize?: number; } /** * Let TypeScript know about optional dependencies */ declare global { var FastEmbed: any; } /** * FastEmbedder * * Efficient local embeddings with minimal resource usage * Uses fastembed library for optimized performance */ export declare class FastEmbedder extends BaseEmbedder<FastEmbedderOptions> { /** * FastEmbed model instance (lazy loaded) */ private model; /** * Whether the model is ready */ private modelReady; /** * Model initialization promise (for concurrent calls) */ private initializationPromise; /** * Whether to use multilingual model */ private multilingual; /** * Path to model cache directory */ private cacheDir; /** * Maximum text length */ private maxLength; /** * Whether to use internal batching */ private useBatching; /** * Internal batch size */ private internalBatchSize; /** * Model path */ protected _modelPath: string; /** * Dimensions of the embeddings */ protected _dimensions: number; /** * Maximum sequence length */ protected _maxLength: number; /** * Whether to use average pooling */ protected _useAveragePooling: boolean; /** * Request timeout in milliseconds */ protected _timeout: number; /** * Model instance */ protected _modelInstance: any; /** * Constructor for FastEmbedder */ constructor(options: FastEmbedderOptions); /** * Internal initialization logic */ private _initializeModel; embed(text: string): Promise<Float32Array>; embedBatch(texts: string[]): Promise<Float32Array[]>; protected executeWithRetry<T>(operation: () => Promise<T>, maxRetries?: number, initialBackoff?: number, maxBackoff?: number): Promise<T>; protected executeBatchWithRetry<T>(operation: () => Promise<T>, maxRetries?: number, initialBackoff?: number, maxBackoff?: number): Promise<T>; protected isTransientError(error: Error): boolean; protected embedText(text: string): Promise<Float32Array>; private initializeModel; } //# sourceMappingURL=FastEmbedder.d.ts.map