Add Google Vertex Auth credential and update langchain version
This commit is contained in:
parent
d408c06ab0
commit
31cb4c1c64
|
|
@ -0,0 +1,25 @@
|
|||
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||
|
||||
class GoogleVertexAuth implements INodeCredential {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Google Vertex Auth'
|
||||
this.name = 'googleVertexAuth'
|
||||
this.version = 1.0
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Google Application Credential File Path',
|
||||
name: 'googleApplicationCredentialFilePath',
|
||||
description: 'Path to your google application credential json file',
|
||||
placeholder: 'your-path/application_default_credentials.json',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { credClass: GoogleVertexAuth }
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { GoogleVertexAIEmbeddings, GoogleVertexAIEmbeddingsParams } from 'langchain/embeddings/googlevertexai'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
|
||||
class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||
label: string
|
||||
|
|
@ -23,6 +23,12 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
|||
this.category = 'Embeddings'
|
||||
this.description = 'Google vertexAI API to generate embeddings for a given text'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(GoogleVertexAIEmbeddings)]
|
||||
this.credential = {
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
credentialNames: ['googleVertexAuth']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Model Name',
|
||||
|
|
@ -43,10 +49,18 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
|||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData, _: string): Promise<any> {
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
const model = nodeData.inputs?.modelName as string
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
|
||||
|
||||
const authOptions = {
|
||||
keyFile: googleApplicationCredentialFilePath,
|
||||
};
|
||||
const obj: GoogleVertexAIEmbeddingsParams = {
|
||||
model
|
||||
model:model,
|
||||
authOptions,
|
||||
|
||||
}
|
||||
|
||||
const embedding = new GoogleVertexAIEmbeddings(obj)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
"google-auth-library": "^9.0.0",
|
||||
"graphql": "^16.6.0",
|
||||
"html-to-text": "^9.0.5",
|
||||
"langchain": "^0.0.117",
|
||||
"langchain": "^0.0.122",
|
||||
"linkifyjs": "^4.1.1",
|
||||
"mammoth": "^1.5.1",
|
||||
"moment": "^2.29.3",
|
||||
|
|
|
|||
Loading…
Reference in New Issue