diff --git a/packages/components/credentials/GoogleSearchApi.credential.ts b/packages/components/credentials/GoogleSearchApi.credential.ts new file mode 100644 index 00000000..ab6d709e --- /dev/null +++ b/packages/components/credentials/GoogleSearchApi.credential.ts @@ -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 } diff --git a/packages/components/nodes/tools/GoogleSearchAPI/GoogleSearchAPI.ts b/packages/components/nodes/tools/GoogleSearchAPI/GoogleSearchAPI.ts index 4fbf7e36..b510b37b 100644 --- a/packages/components/nodes/tools/GoogleSearchAPI/GoogleSearchAPI.ts +++ b/packages/components/nodes/tools/GoogleSearchAPI/GoogleSearchAPI.ts @@ -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 { 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 }