diff --git a/libs/langchain-community/src/embeddings/hf_transformers.ts b/libs/langchain-community/src/embeddings/hf_transformers.ts index 0de31abdd139..adcde32fe7fe 100644 --- a/libs/langchain-community/src/embeddings/hf_transformers.ts +++ b/libs/langchain-community/src/embeddings/hf_transformers.ts @@ -1,6 +1,8 @@ -import { Pipeline, pipeline } from "@xenova/transformers"; +import { Pipeline } from "@xenova/transformers"; import { Embeddings, type EmbeddingsParams } from "@langchain/core/embeddings"; import { chunkArray } from "@langchain/core/utils/chunk_array"; +const TransformersApi = Function('return import("@xenova/transformers")')(); + export interface HuggingFaceTransformersEmbeddingsParams extends EmbeddingsParams { @@ -100,6 +102,7 @@ export class HuggingFaceTransformersEmbeddings } private async runEmbedding(texts: string[]) { + const { pipeline } = await TransformersApi; const pipe = await (this.pipelinePromise ??= pipeline( "feature-extraction", this.model