Skip to content

Commit b2d3c7f

Browse files
isengartzJJK801
authored andcommitted
Adding Tavily custom tool (FlowiseAI#4027)
Adding Tavily custom tool
1 parent 48b3546 commit b2d3c7f

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { INodeParams, INodeCredential } from '../src/Interface'
2+
3+
class TavilyApi implements INodeCredential {
4+
label: string
5+
name: string
6+
version: number
7+
description: string
8+
inputs: INodeParams[]
9+
10+
constructor() {
11+
this.label = 'Tavily API'
12+
this.name = 'tavilyApi'
13+
this.version = 1.0
14+
this.description = 'Tavily API is a real-time API to access Google search results'
15+
this.inputs = [
16+
{
17+
label: 'Tavily Api Key',
18+
name: 'tavilyApiKey',
19+
type: 'password'
20+
}
21+
]
22+
}
23+
}
24+
25+
module.exports = { credClass: TavilyApi }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { TavilySearchResults } from '@langchain/community/tools/tavily_search'
2+
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
3+
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
4+
5+
class TavilyAPI_Tools implements INode {
6+
label: string
7+
name: string
8+
version: number
9+
description: string
10+
type: string
11+
icon: string
12+
category: string
13+
baseClasses: string[]
14+
credential: INodeParams
15+
inputs: INodeParams[]
16+
17+
constructor() {
18+
this.label = 'Tavily API'
19+
this.name = 'tavilyAPI'
20+
this.version = 1.0
21+
this.type = 'TavilyAPI'
22+
this.icon = 'tavily.svg'
23+
this.category = 'Tools'
24+
this.description = 'Wrapper around TavilyAPI - a real-time API to access Google search results'
25+
this.inputs = []
26+
this.credential = {
27+
label: 'Connect Credential',
28+
name: 'credential',
29+
type: 'credential',
30+
credentialNames: ['tavilyApi']
31+
}
32+
this.baseClasses = [this.type, ...getBaseClasses(TavilySearchResults)]
33+
}
34+
35+
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
36+
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
37+
const tavilyApiKey = getCredentialParam('tavilyApiKey', credentialData, nodeData)
38+
return new TavilySearchResults({ apiKey: tavilyApiKey })
39+
}
40+
}
41+
42+
module.exports = { nodeClass: TavilyAPI_Tools }
Loading

0 commit comments

Comments
 (0)