Add input option for Model Name in GoogleVertexAIEmbedding

This commit is contained in:
Yongtae
2023-09-03 19:12:42 +09:00
parent 8f83bb6700
commit a05d73d83b
@@ -33,11 +33,35 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
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.'
}
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,
additionalParams: true
}
]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const modelName = nodeData.inputs?.modelName ?? 'textembedding-gecko@001'
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
const projectID = getCredentialParam('projectID', credentialData, nodeData)
@@ -58,7 +82,9 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
if (projectID) authOptions.projectId = projectID
}
const obj: GoogleVertexAIEmbeddingsParams = {}
const obj: GoogleVertexAIEmbeddingsParams = {
model: modelName
}
if (Object.keys(authOptions).length !== 0) obj.authOptions = authOptions
const model = new GoogleVertexAIEmbeddings(obj)