diff --git a/packages/components/credentials/TavilyApi.credential.ts b/packages/components/credentials/TavilyApi.credential.ts new file mode 100644 index 00000000000..161ff4df0b0 --- /dev/null +++ b/packages/components/credentials/TavilyApi.credential.ts @@ -0,0 +1,25 @@ +import { INodeParams, INodeCredential } from '../src/Interface' + +class TavilyApi implements INodeCredential { + label: string + name: string + version: number + description: string + inputs: INodeParams[] + + constructor() { + this.label = 'Tavily API' + this.name = 'tavilyApi' + this.version = 1.0 + this.description = 'Tavily API is a real-time API to access Google search results' + this.inputs = [ + { + label: 'Tavily Api Key', + name: 'tavilyApiKey', + type: 'password' + } + ] + } +} + +module.exports = { credClass: TavilyApi } diff --git a/packages/components/nodes/tools/TavilyAPI/TavilyAPI.ts b/packages/components/nodes/tools/TavilyAPI/TavilyAPI.ts new file mode 100644 index 00000000000..68e44c54670 --- /dev/null +++ b/packages/components/nodes/tools/TavilyAPI/TavilyAPI.ts @@ -0,0 +1,42 @@ +import { TavilySearchResults } from '@langchain/community/tools/tavily_search' +import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class TavilyAPI_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 = 'Tavily API' + this.name = 'tavilyAPI' + this.version = 1.0 + this.type = 'TavilyAPI' + this.icon = 'tavily.svg' + this.category = 'Tools' + this.description = 'Wrapper around TavilyAPI - a real-time API to access Google search results' + this.inputs = [] + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['tavilyApi'] + } + this.baseClasses = [this.type, ...getBaseClasses(TavilySearchResults)] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const tavilyApiKey = getCredentialParam('tavilyApiKey', credentialData, nodeData) + return new TavilySearchResults({ apiKey: tavilyApiKey }) + } +} + +module.exports = { nodeClass: TavilyAPI_Tools } diff --git a/packages/components/nodes/tools/TavilyAPI/tavily.svg b/packages/components/nodes/tools/TavilyAPI/tavily.svg new file mode 100644 index 00000000000..141d1d3d6e5 --- /dev/null +++ b/packages/components/nodes/tools/TavilyAPI/tavily.svg @@ -0,0 +1 @@ + \ No newline at end of file