Add credentials file
This commit is contained in:
parent
62a13630b9
commit
1832eecde2
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||||
|
|
||||||
|
class VectaraAPI implements INodeCredential {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
version: number
|
||||||
|
description: string
|
||||||
|
inputs: INodeParams[]
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.label = 'Vectara API'
|
||||||
|
this.name = 'vectaraApi'
|
||||||
|
this.version = 1.0
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Vectara Customer ID',
|
||||||
|
name: 'customerID',
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Vectara Corpus ID',
|
||||||
|
name: 'corpusID',
|
||||||
|
type: 'string'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Vectara API Key',
|
||||||
|
name: 'apiKey',
|
||||||
|
type: 'password'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { credClass: VectaraAPI }
|
||||||
|
|
@ -1,42 +1,36 @@
|
||||||
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { VectaraStore, VectaraLibArgs, VectaraFilter } from 'langchain/vectorstores/vectara'
|
import { VectaraStore, VectaraLibArgs, VectaraFilter } from 'langchain/vectorstores/vectara'
|
||||||
|
|
||||||
class VectaraExisting_VectorStores implements INode {
|
class VectaraExisting_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
name: string
|
name: string
|
||||||
|
version: number
|
||||||
description: string
|
description: string
|
||||||
type: string
|
type: string
|
||||||
icon: string
|
icon: string
|
||||||
category: string
|
category: string
|
||||||
baseClasses: string[]
|
baseClasses: string[]
|
||||||
inputs: INodeParams[]
|
inputs: INodeParams[]
|
||||||
|
credential: INodeParams
|
||||||
outputs: INodeOutputsValue[]
|
outputs: INodeOutputsValue[]
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Vectara Load Existing Index'
|
this.label = 'Vectara Load Existing Index'
|
||||||
this.name = 'vectaraExistingIndex'
|
this.name = 'vectaraExistingIndex'
|
||||||
|
this.version = 1.0
|
||||||
this.type = 'Vectara'
|
this.type = 'Vectara'
|
||||||
this.icon = 'vectara.png'
|
this.icon = 'vectara.png'
|
||||||
this.category = 'Vector Stores'
|
this.category = 'Vector Stores'
|
||||||
this.description = 'Load existing index from Vectara (i.e: Document has been upserted)'
|
this.description = 'Load existing index from Vectara (i.e: Document has been upserted)'
|
||||||
this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever']
|
this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever']
|
||||||
|
this.credential = {
|
||||||
|
label: 'Connect Credential',
|
||||||
|
name: 'credential',
|
||||||
|
type: 'credential',
|
||||||
|
credentialNames: ['vectaraApi']
|
||||||
|
}
|
||||||
this.inputs = [
|
this.inputs = [
|
||||||
{
|
|
||||||
label: 'Vectara Customer ID',
|
|
||||||
name: 'customerID',
|
|
||||||
type: 'string'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Vectara Corpus ID',
|
|
||||||
name: 'corpusID',
|
|
||||||
type: 'string'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Vectara API Key',
|
|
||||||
name: 'apiKey',
|
|
||||||
type: 'password'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Vectara Metadata Filter',
|
label: 'Vectara Metadata Filter',
|
||||||
name: 'filter',
|
name: 'filter',
|
||||||
|
|
@ -74,10 +68,12 @@ class VectaraExisting_VectorStores implements INode {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
async init(nodeData: INodeData): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const customerId = nodeData.inputs?.customerID as number
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const corpusId = nodeData.inputs?.corpusID as number
|
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
||||||
const apiKey = nodeData.inputs?.apiKey as string
|
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
||||||
|
const corpusId = getCredentialParam('corpusID', credentialData, nodeData)
|
||||||
|
|
||||||
const vectaraMetadatafilter = nodeData.inputs?.filter as VectaraFilter
|
const vectaraMetadatafilter = nodeData.inputs?.filter as VectaraFilter
|
||||||
const lambda = nodeData.inputs?.lambda as number
|
const lambda = nodeData.inputs?.lambda as number
|
||||||
const output = nodeData.outputs?.output as string
|
const output = nodeData.outputs?.output as string
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
import { ICommonObject, INode, INodeData, INodeOutputsValue, INodeParams } from '../../../src/Interface'
|
||||||
import { Embeddings } from 'langchain/embeddings/base'
|
import { Embeddings } from 'langchain/embeddings/base'
|
||||||
import { getBaseClasses } from '../../../src/utils'
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { VectaraStore, VectaraLibArgs, VectaraFilter } from 'langchain/vectorstores/vectara'
|
import { VectaraStore, VectaraLibArgs, VectaraFilter } from 'langchain/vectorstores/vectara'
|
||||||
import { Document } from 'langchain/document'
|
import { Document } from 'langchain/document'
|
||||||
import { flatten } from 'lodash'
|
import { flatten } from 'lodash'
|
||||||
|
|
@ -8,38 +8,32 @@ import { flatten } from 'lodash'
|
||||||
class VectaraExisting_VectorStores implements INode {
|
class VectaraExisting_VectorStores implements INode {
|
||||||
label: string
|
label: string
|
||||||
name: string
|
name: string
|
||||||
|
version: number
|
||||||
description: string
|
description: string
|
||||||
type: string
|
type: string
|
||||||
icon: string
|
icon: string
|
||||||
category: string
|
category: string
|
||||||
baseClasses: string[]
|
baseClasses: string[]
|
||||||
inputs: INodeParams[]
|
inputs: INodeParams[]
|
||||||
|
credential: INodeParams
|
||||||
outputs: INodeOutputsValue[]
|
outputs: INodeOutputsValue[]
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Vectara Upsert Document'
|
this.label = 'Vectara Upsert Document'
|
||||||
this.name = 'vectaraExisting'
|
this.name = 'vectaraExisting'
|
||||||
|
this.version = 1.0
|
||||||
this.type = 'Vectara'
|
this.type = 'Vectara'
|
||||||
this.icon = 'vectara.png'
|
this.icon = 'vectara.png'
|
||||||
this.category = 'Vector Stores'
|
this.category = 'Vector Stores'
|
||||||
this.description = 'Upsert documents to Vectara'
|
this.description = 'Upsert documents to Vectara'
|
||||||
this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever']
|
this.baseClasses = [this.type, 'VectorStoreRetriever', 'BaseRetriever']
|
||||||
|
this.credential = {
|
||||||
|
label: 'Connect Credential',
|
||||||
|
name: 'credential',
|
||||||
|
type: 'credential',
|
||||||
|
credentialNames: ['vectaraApi']
|
||||||
|
}
|
||||||
this.inputs = [
|
this.inputs = [
|
||||||
{
|
|
||||||
label: 'Vectara Customer ID',
|
|
||||||
name: 'customerID',
|
|
||||||
type: 'string'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Vectara Corpus ID',
|
|
||||||
name: 'corpusID',
|
|
||||||
type: 'string'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Vectara API Key',
|
|
||||||
name: 'apiKey',
|
|
||||||
type: 'password'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Document',
|
label: 'Document',
|
||||||
name: 'document',
|
name: 'document',
|
||||||
|
|
@ -83,10 +77,12 @@ class VectaraExisting_VectorStores implements INode {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
async init(nodeData: INodeData): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const customerId = nodeData.inputs?.customerID as number
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const corpusId = nodeData.inputs?.corpusID as number
|
const apiKey = getCredentialParam('apiKey', credentialData, nodeData)
|
||||||
const apiKey = nodeData.inputs?.apiKey as string
|
const customerId = getCredentialParam('customerID', credentialData, nodeData)
|
||||||
|
const corpusId = getCredentialParam('corpusID', credentialData, nodeData)
|
||||||
|
|
||||||
const docs = nodeData.inputs?.document as Document[]
|
const docs = nodeData.inputs?.document as Document[]
|
||||||
const embeddings = {} as Embeddings
|
const embeddings = {} as Embeddings
|
||||||
const vectaraMetadatafilter = nodeData.inputs?.filter as VectaraFilter
|
const vectaraMetadatafilter = nodeData.inputs?.filter as VectaraFilter
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue