update credentials

This commit is contained in:
Henry
2023-07-15 19:43:09 +01:00
parent d76a47b894
commit ff755c3d1b
75 changed files with 911 additions and 461 deletions
@@ -1,7 +1,7 @@
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
import { Embeddings } from 'langchain/embeddings/base'
import { Document } from 'langchain/document'
import { getBaseClasses } from '../../../src/utils'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
import { SupabaseVectorStore } from 'langchain/vectorstores/supabase'
import { createClient } from '@supabase/supabase-js'
import { flatten } from 'lodash'
@@ -15,6 +15,7 @@ class SupabaseUpsert_VectorStores implements INode {
category: string
baseClasses: string[]
inputs: INodeParams[]
credential: INodeParams
outputs: INodeOutputsValue[]
constructor() {
@@ -25,6 +26,12 @@ class SupabaseUpsert_VectorStores implements INode {
this.category = 'Vector Stores'
this.description = 'Upsert documents to Supabase'
this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever']
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['supabaseApi']
}
this.inputs = [
{
label: 'Document',
@@ -37,11 +44,6 @@ class SupabaseUpsert_VectorStores implements INode {
name: 'embeddings',
type: 'Embeddings'
},
{
label: 'Supabase API Key',
name: 'supabaseApiKey',
type: 'password'
},
{
label: 'Supabase Project URL',
name: 'supabaseProjUrl',
@@ -81,8 +83,7 @@ class SupabaseUpsert_VectorStores implements INode {
]
}
async init(nodeData: INodeData): Promise<any> {
const supabaseApiKey = nodeData.inputs?.supabaseApiKey as string
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const supabaseProjUrl = nodeData.inputs?.supabaseProjUrl as string
const tableName = nodeData.inputs?.tableName as string
const queryName = nodeData.inputs?.queryName as string
@@ -92,6 +93,9 @@ class SupabaseUpsert_VectorStores implements INode {
const topK = nodeData.inputs?.topK as string
const k = topK ? parseInt(topK, 10) : 4
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const supabaseApiKey = getCredentialParam('supabaseApiKey', credentialData, nodeData)
const client = createClient(supabaseProjUrl, supabaseApiKey)
const flattenDocs = docs && docs.length ? flatten(docs) : []