@claude-flow/embeddings
Version:
V3 Embedding Service - OpenAI, Transformers.js, Agentic-Flow (ONNX), Mock providers with hyperbolic embeddings, normalization, and chunking
34 lines • 1.54 kB
TypeScript
/**
* Provider-agnostic transformers loader.
*
* ADR-094: prefer the maintained `@huggingface/transformers` (which
* pulls in `protobufjs >=7.5.5` and clears the critical RCE CVE
* chain), fall back to the legacy `@xenova/transformers` for
* backwards compatibility with consumers who haven't installed the
* new package yet.
*
* Both packages export the same `pipeline()` function with compatible
* signatures for our usage (`pipeline('feature-extraction', modelId)`),
* so callers can use the returned function transparently. The `source`
* field is reported through `embeddings_status.ruvectorStatus` so
* users can see which package satisfied the runtime.
*/
export type PipelineFn = (task: string, model?: string, options?: Record<string, unknown>) => Promise<unknown>;
export interface TransformersHandle {
pipeline: PipelineFn;
source: '@huggingface/transformers' | '@xenova/transformers';
version?: string;
}
/**
* Load a working transformers pipeline. Returns null if neither
* package is installed. Caches the first successful resolution so
* subsequent calls don't re-import.
*/
export declare function loadTransformersPipeline(): Promise<TransformersHandle | null>;
/**
* Synchronous probe — returns whether either package was loaded
* during a previous call to `loadTransformersPipeline()`. For status
* tools that don't want to trigger a fresh import.
*/
export declare function getCachedTransformersSource(): TransformersHandle | null;
//# sourceMappingURL=transformers-loader.d.ts.map