mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-10-22 15:28:13 +00:00
feat(providers): add transformers provider
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Embeddings, type EmbeddingsParams } from '@langchain/core/embeddings';
|
||||
import { chunkArray } from '@langchain/core/utils/chunk_array';
|
||||
import { pipeline } from '@huggingface/transformers';
|
||||
|
||||
export interface HuggingFaceTransformersEmbeddingsParams
|
||||
extends EmbeddingsParams {
|
||||
@@ -67,12 +68,7 @@ export class HuggingFaceTransformersEmbeddings
|
||||
}
|
||||
|
||||
private async runEmbedding(texts: string[]) {
|
||||
const { pipeline } = await import('@xenova/transformers');
|
||||
|
||||
const pipe = await (this.pipelinePromise ??= pipeline(
|
||||
'feature-extraction',
|
||||
this.model,
|
||||
));
|
||||
const pipe = await pipeline('feature-extraction', this.model);
|
||||
|
||||
return this.caller.call(async () => {
|
||||
const output = await pipe(texts, { pooling: 'mean', normalize: true });
|
||||
|
Reference in New Issue
Block a user