Merge branch 'main' into feature/Migration

This commit is contained in:
chungyau97
2023-09-05 13:59:46 +08:00
@@ -33,11 +33,34 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
description: description:
'Google Vertex AI credential. If you are using a GCP service like Cloud Run, or if you have installed default credentials on your local machine, you do not need to set this credential.' 'Google Vertex AI credential. If you are using a GCP service like Cloud Run, or if you have installed default credentials on your local machine, you do not need to set this credential.'
} }
this.inputs = [] this.inputs = [
{
label: 'Model Name',
name: 'modelName',
type: 'options',
options: [
{
label: 'textembedding-gecko@001',
name: 'textembedding-gecko@001'
},
{
label: 'textembedding-gecko@latest',
name: 'textembedding-gecko@latest'
},
{
label: 'textembedding-gecko-multilingual@latest',
name: 'textembedding-gecko-multilingual@latest'
}
],
default: 'textembedding-gecko@001',
optional: true
}
]
} }
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> { async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const credentialData = await getCredentialData(nodeData.credential ?? '', options) const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const modelName = nodeData.inputs?.modelName as string
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData) const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData) const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
const projectID = getCredentialParam('projectID', credentialData, nodeData) const projectID = getCredentialParam('projectID', credentialData, nodeData)
@@ -59,6 +82,7 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
if (projectID) authOptions.projectId = projectID if (projectID) authOptions.projectId = projectID
} }
const obj: GoogleVertexAIEmbeddingsParams = {} const obj: GoogleVertexAIEmbeddingsParams = {}
if (modelName) obj.model = modelName
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
const model = new GoogleVertexAIEmbeddings(obj) const model = new GoogleVertexAIEmbeddings(obj)