Added google custom search credential

pull/646/head
denchi 2023-07-29 11:20:00 +01:00
parent 7511d82c83
commit 2fcb2ea88e
2 changed files with 37 additions and 7 deletions

View File

@ -0,0 +1,29 @@
import { INodeParams, INodeCredential } from '../src/Interface'
class GoogleSearchApi implements INodeCredential {
label: string
name: string
version: number
description: string
inputs: INodeParams[]
constructor() {
this.label = 'Google Custom Search API'
this.name = 'googleCustomSearchApi'
this.version = 1.0
this.inputs = [
{
label: 'Google Custom Search Api Key',
name: 'googleCustomSearchApiKey',
type: 'password'
},
{
label: 'Programmable Search Engine ID',
name: 'googleCustomSearchApiId',
type: 'string'
}
]
}
}
module.exports = { credClass: GoogleSearchApi }

View File

@ -3,7 +3,7 @@ import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../
import { GoogleCustomSearch } from 'langchain/tools'
class GoogleSearchAPI_Tools implements INode {
class GoogleCustomSearchAPI_Tools implements INode {
label: string
name: string
version: number
@ -17,9 +17,9 @@ class GoogleSearchAPI_Tools implements INode {
constructor() {
this.label = 'Google Custom Search'
this.name = 'googleSearchAPI'
this.name = 'googleCustomSearch'
this.version = 1.0
this.type = 'GoogleSearchAPI'
this.type = 'GoogleCustomSearchAPI'
this.icon = 'google.png'
this.category = 'Tools'
this.description = 'Wrapper around Google Custom Search API - a real-time API to access Google search results'
@ -28,16 +28,17 @@ class GoogleSearchAPI_Tools implements INode {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['googleSearchApi']
credentialNames: ['googleCustomSearchApi']
}
this.baseClasses = [this.type, ...getBaseClasses(GoogleCustomSearch)]
}
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const googleApiKey = getCredentialParam('googleApiKey', credentialData, nodeData)
return new GoogleCustomSearch({ apiKey: googleApiKey })
const googleApiKey = getCredentialParam('googleCustomSearchApiKey', credentialData, nodeData)
const googleCseId = getCredentialParam('googleCustomSearchApiId', credentialData, nodeData)
return new GoogleCustomSearch({ apiKey: googleApiKey, googleCSEId: googleCseId })
}
}
module.exports = { nodeClass: GoogleSearchAPI_Tools }
module.exports = { nodeClass: GoogleCustomSearchAPI_Tools }