mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Added google custom search credential
This commit is contained in:
@@ -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 }
|
||||||
@@ -3,7 +3,7 @@ import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../
|
|||||||
import { GoogleCustomSearch } from 'langchain/tools'
|
import { GoogleCustomSearch } from 'langchain/tools'
|
||||||
|
|
||||||
|
|
||||||
class GoogleSearchAPI_Tools implements INode {
|
class GoogleCustomSearchAPI_Tools implements INode {
|
||||||
label: string
|
label: string
|
||||||
name: string
|
name: string
|
||||||
version: number
|
version: number
|
||||||
@@ -17,9 +17,9 @@ class GoogleSearchAPI_Tools implements INode {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Google Custom Search'
|
this.label = 'Google Custom Search'
|
||||||
this.name = 'googleSearchAPI'
|
this.name = 'googleCustomSearch'
|
||||||
this.version = 1.0
|
this.version = 1.0
|
||||||
this.type = 'GoogleSearchAPI'
|
this.type = 'GoogleCustomSearchAPI'
|
||||||
this.icon = 'google.png'
|
this.icon = 'google.png'
|
||||||
this.category = 'Tools'
|
this.category = 'Tools'
|
||||||
this.description = 'Wrapper around Google Custom Search API - a real-time API to access Google search results'
|
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',
|
label: 'Connect Credential',
|
||||||
name: 'credential',
|
name: 'credential',
|
||||||
type: 'credential',
|
type: 'credential',
|
||||||
credentialNames: ['googleSearchApi']
|
credentialNames: ['googleCustomSearchApi']
|
||||||
}
|
}
|
||||||
this.baseClasses = [this.type, ...getBaseClasses(GoogleCustomSearch)]
|
this.baseClasses = [this.type, ...getBaseClasses(GoogleCustomSearch)]
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
const googleApiKey = getCredentialParam('googleApiKey', credentialData, nodeData)
|
const googleApiKey = getCredentialParam('googleCustomSearchApiKey', credentialData, nodeData)
|
||||||
return new GoogleCustomSearch({ apiKey: googleApiKey })
|
const googleCseId = getCredentialParam('googleCustomSearchApiId', credentialData, nodeData)
|
||||||
|
return new GoogleCustomSearch({ apiKey: googleApiKey, googleCSEId: googleCseId })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { nodeClass: GoogleSearchAPI_Tools }
|
module.exports = { nodeClass: GoogleCustomSearchAPI_Tools }
|
||||||
|
|||||||
Reference in New Issue
Block a user