diff --git a/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts b/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts new file mode 100644 index 000000000..26433bc05 --- /dev/null +++ b/packages/components/nodes/vectorstores/Supabase_Existing/Supabase_Exisiting.ts @@ -0,0 +1,93 @@ +import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface' +import { Embeddings } from 'langchain/embeddings/base' +import { getBaseClasses } from '../../../src/utils' +import { SupabaseVectorStore } from 'langchain/vectorstores/supabase' +import { createClient } from '@supabase/supabase-js' + +class Supabase_Existing_VectorStores implements INode { + label: string + name: string + description: string + type: string + icon: string + category: string + baseClasses: string[] + inputs: INodeParams[] + outputs: INodeOutputsValue[] + + constructor() { + this.label = 'Supabase Load Existing Index' + this.name = 'supabaseExistingIndex' + this.type = 'Supabase' + this.icon = 'supabase.svg' + this.category = 'Vector Stores' + this.description = 'Load existing index from Supabase (i.e: Document has been upserted)' + this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever'] + this.inputs = [ + { + label: 'Embeddings', + name: 'embeddings', + type: 'Embeddings' + }, + { + label: 'Supabase API Key', + name: 'supabaseApiKey', + type: 'password' + }, + { + label: 'Supabase Project URL', + name: 'supabaseProjUrl', + type: 'string' + }, + { + label: 'Table Name', + name: 'tableName', + type: 'string' + }, + { + label: 'Query Name', + name: 'queryName', + type: 'string' + } + ] + this.outputs = [ + { + label: 'Supabase Retriever', + name: 'retriever', + baseClasses: this.baseClasses + }, + { + label: 'Supabase Vector Store', + name: 'vectorStore', + baseClasses: [this.type, ...getBaseClasses(SupabaseVectorStore)] + } + ] + } + + async init(nodeData: INodeData): Promise { + const supabaseApiKey = nodeData.inputs?.supabaseApiKey as string + const supabaseProjUrl = nodeData.inputs?.supabaseProjUrl as string + const tableName = nodeData.inputs?.tableName as string + const queryName = nodeData.inputs?.queryName as string + const embeddings = nodeData.inputs?.embeddings as Embeddings + const output = nodeData.outputs?.output as string + + const client = createClient(supabaseProjUrl, supabaseApiKey) + + const vectorStore = await SupabaseVectorStore.fromExistingIndex(embeddings, { + client, + tableName: tableName, + queryName: queryName + }) + + if (output === 'retriever') { + const retriever = vectorStore.asRetriever() + return retriever + } else if (output === 'vectorStore') { + return vectorStore + } + return vectorStore + } +} + +module.exports = { nodeClass: Supabase_Existing_VectorStores } diff --git a/packages/components/nodes/vectorstores/Supabase_Existing/supabase.svg b/packages/components/nodes/vectorstores/Supabase_Existing/supabase.svg new file mode 100644 index 000000000..884d6449f --- /dev/null +++ b/packages/components/nodes/vectorstores/Supabase_Existing/supabase.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts b/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts index 3f1f91709..ff4fe3f8c 100644 --- a/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts +++ b/packages/components/nodes/vectorstores/Supabase_Upsert/Supabase_Upsert.ts @@ -19,7 +19,7 @@ class SupabaseUpsert_VectorStores implements INode { constructor() { this.label = 'Supabase Upsert Document' this.name = 'supabaseUpsert' - this.type = 'supabase' + this.type = 'Supabase' this.icon = 'supabase.svg' this.category = 'Vector Stores' this.description = 'Upsert documents to Supabase'