mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Merge pull request #646 from denchi/feature/GoogleCustomSearch
Feature/google custom search
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
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.description =
|
||||||
|
'Please refer to the <a target="_blank" href="https://console.cloud.google.com/apis/credentials">Google Cloud Console</a> for instructions on how to create an API key, and visit the <a target="_blank" href="https://programmablesearchengine.google.com/controlpanel/create">Search Engine Creation page</a> to learn how to generate your Search Engine ID.'
|
||||||
|
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 }
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
|
import { GoogleCustomSearch } from 'langchain/tools'
|
||||||
|
|
||||||
|
class GoogleCustomSearchAPI_Tools implements INode {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
version: number
|
||||||
|
description: string
|
||||||
|
type: string
|
||||||
|
icon: string
|
||||||
|
category: string
|
||||||
|
baseClasses: string[]
|
||||||
|
credential: INodeParams
|
||||||
|
inputs: INodeParams[]
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.label = 'Google Custom Search'
|
||||||
|
this.name = 'googleCustomSearch'
|
||||||
|
this.version = 1.0
|
||||||
|
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'
|
||||||
|
this.inputs = []
|
||||||
|
this.credential = {
|
||||||
|
label: 'Connect Credential',
|
||||||
|
name: 'credential',
|
||||||
|
type: 'credential',
|
||||||
|
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('googleCustomSearchApiKey', credentialData, nodeData)
|
||||||
|
const googleCseId = getCredentialParam('googleCustomSearchApiId', credentialData, nodeData)
|
||||||
|
return new GoogleCustomSearch({ apiKey: googleApiKey, googleCSEId: googleCseId })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { nodeClass: GoogleCustomSearchAPI_Tools }
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
Reference in New Issue
Block a user