mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Refactor GoogleAuth.credential to support both file path and JSON object credentials. Update GoogleVertexAIEmbedding to handle both cases
This commit is contained in:
+10
-4
@@ -36,12 +36,18 @@ class GoogleVertexAIEmbedding_Embeddings implements INode {
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const googleApplicationCredentialFilePath = getCredentialParam('googleApplicationCredentialFilePath', credentialData, nodeData)
|
||||
if (!googleApplicationCredentialFilePath) throw new Error('Please specify your Google Application Credential file path')
|
||||
const googleApplicationCredential = getCredentialParam('googleApplicationCredential', credentialData, nodeData)
|
||||
const projectID = getCredentialParam('projectID', credentialData, nodeData)
|
||||
|
||||
const authOptions: GoogleAuthOptions = {
|
||||
keyFile: googleApplicationCredentialFilePath
|
||||
}
|
||||
if (!googleApplicationCredentialFilePath && !googleApplicationCredential)
|
||||
throw new Error('Please specify your Google Application Credential')
|
||||
if (googleApplicationCredentialFilePath && googleApplicationCredential)
|
||||
throw new Error('Please use either Google Application Credential File Path or Google Credential JSON Object')
|
||||
|
||||
const authOptions: GoogleAuthOptions = {}
|
||||
if (googleApplicationCredentialFilePath && !googleApplicationCredential) authOptions.keyFile = googleApplicationCredentialFilePath
|
||||
else if (!googleApplicationCredentialFilePath && googleApplicationCredential)
|
||||
authOptions.credentials = JSON.parse(googleApplicationCredential)
|
||||
|
||||
if (projectID) authOptions.projectId = projectID
|
||||
|
||||
|
||||
Reference in New Issue
Block a user