move project id and remove location

This commit is contained in:
Yongtae
2023-08-07 12:11:35 +09:00
parent d6844655cc
commit a0d0d5e6e3
2 changed files with 10 additions and 21 deletions
@@ -17,6 +17,14 @@ class GoogleVertexAuth implements INodeCredential {
description: 'Path to your google application credential json file', description: 'Path to your google application credential json file',
placeholder: 'your-path/application_default_credentials.json', placeholder: 'your-path/application_default_credentials.json',
type: 'string' type: 'string'
},
{
label: 'Project ID',
name: 'projectID',
description: 'Project ID of GCP. If not provided, it will be read from the credential file',
type: 'string',
optional: true,
additionalParams: true
} }
] ]
} }
@@ -30,32 +30,14 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
type: 'credential', type: 'credential',
credentialNames: ['googleVertexAuth'] credentialNames: ['googleVertexAuth']
} }
this.inputs = [ this.inputs = []
{
label: 'Project ID',
name: 'projectID',
description: 'project id of GCP',
type: 'string',
additionalParams: true,
optional: true
},
{
label: 'location',
name: 'location',
description: 'location of API',
type: 'string',
additionalParams: true,
optional: true
}
]
} }
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> { async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const projectID = nodeData.inputs?.projectID as string
const location = nodeData.inputs?.location as string
const credentialData = await getCredentialData(nodeData.credential ?? '', options) const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData) const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
if (!googleApplicationCredentialFilePath) throw new Error('Please specify your Google Application Credential file path') if (!googleApplicationCredentialFilePath) throw new Error('Please specify your Google Application Credential file path')
const projectID = getCredentialParam('projectID', credentialData, nodeData)
const authOptions: GoogleAuthOptions = { const authOptions: GoogleAuthOptions = {
keyFile: googleApplicationCredentialFilePath keyFile: googleApplicationCredentialFilePath
@@ -66,7 +48,6 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
const obj: GoogleVertexAIEmbeddingsParams = { const obj: GoogleVertexAIEmbeddingsParams = {
authOptions authOptions
} }
if (location) obj.location = location
const model = new GoogleVertexAIEmbeddings(obj) const model = new GoogleVertexAIEmbeddings(obj)
return model return model