diff --git a/packages/components/nodes/embeddings/TensorFlowEmbedding/TensorFlow.svg b/packages/components/nodes/embeddings/TensorFlowEmbedding/TensorFlow.svg new file mode 100644 index 00000000..a38e1aa0 --- /dev/null +++ b/packages/components/nodes/embeddings/TensorFlowEmbedding/TensorFlow.svg @@ -0,0 +1,19 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/components/nodes/embeddings/TensorFlowEmbedding/TensorFlowEmbedding.ts b/packages/components/nodes/embeddings/TensorFlowEmbedding/TensorFlowEmbedding.ts new file mode 100644 index 00000000..f6dcb5ce --- /dev/null +++ b/packages/components/nodes/embeddings/TensorFlowEmbedding/TensorFlowEmbedding.ts @@ -0,0 +1,34 @@ +import { INode } from '../../../src/Interface' +import { getBaseClasses } from '../../../src/utils' +import '@tensorflow/tfjs-node' +import { TensorFlowEmbeddings, TensorFlowEmbeddingsParams } from 'langchain/embeddings/tensorflow' + +class TensorFlowEmbedding_Embeddings implements INode { + label: string + name: string + type: string + icon: string + category: string + description: string + baseClasses: string[] + + constructor() { + this.label = 'TensorFlow Embeddings' + this.name = 'tensorFlowEmbeddings' + this.type = 'TensorFlowEmbeddings' + this.icon = 'TensorFlow.svg' + this.category = 'Embeddings' + this.description = 'TensorFlow.js to generate embeddings for a given text' + this.baseClasses = [this.type, ...getBaseClasses(TensorFlowEmbeddings)] + } + + async init(): Promise { + const obj: Partial = {} + + const model = new TensorFlowEmbeddings(obj) + + return model + } +} + +module.exports = { nodeClass: TensorFlowEmbedding_Embeddings } diff --git a/packages/components/package.json b/packages/components/package.json index dd3c0fc5..95283717 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -20,6 +20,10 @@ "@huggingface/inference": "^1.6.3", "@pinecone-database/pinecone": "^0.0.12", "@supabase/supabase-js": "^2.21.0", + "@tensorflow-models/universal-sentence-encoder": "^1.3.3", + "@tensorflow/tfjs-converter": "^4.6.0", + "@tensorflow/tfjs-core": "^4.6.0", + "@tensorflow/tfjs-node": "^4.6.0", "axios": "^0.27.2", "cheerio": "^1.0.0-rc.12", "chromadb": "^1.3.1",