diff --git a/packages/components/credentials/WolframAlphaApp.credential.ts b/packages/components/credentials/WolframAlphaApp.credential.ts new file mode 100644 index 000000000..69daae4a1 --- /dev/null +++ b/packages/components/credentials/WolframAlphaApp.credential.ts @@ -0,0 +1,25 @@ +import { INodeParams, INodeCredential } from '../src/Interface' + +class WolframAlphaApp implements INodeCredential { + label: string + name: string + version: number + description: string + inputs: INodeParams[] + + constructor() { + this.label = 'WolframAlpha App ID' + this.name = 'wolframAlphaAppId' + this.version = 1.0 + this.description = 'Get an App Id from Wolfram Alpha Portal' + this.inputs = [ + { + label: 'App ID', + name: 'wolframAlphaAppId', + type: 'password' + } + ] + } +} + +module.exports = { credClass: WolframAlphaApp } diff --git a/packages/components/nodes/tools/WolframAlpha/WolframAlpha.ts b/packages/components/nodes/tools/WolframAlpha/WolframAlpha.ts new file mode 100644 index 000000000..8342c1295 --- /dev/null +++ b/packages/components/nodes/tools/WolframAlpha/WolframAlpha.ts @@ -0,0 +1,44 @@ +import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha' +import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface' +import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils' + +class WolframAlpha_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 = 'WolframAlpha' + this.name = 'wolframAlpha' + this.version = 1.0 + this.type = 'WolframAlpha' + this.icon = 'wolframalpha.png' + this.category = 'Tools' + this.description = 'Wrapper around WolframAlpha - a powerful computational knowledge engine' + this.inputs = [] + this.credential = { + label: 'Connect Credential', + name: 'credential', + type: 'credential', + credentialNames: ['wolframAlphaAppId'] + } + this.baseClasses = [this.type, ...getBaseClasses(WolframAlphaTool)] + } + + async init(nodeData: INodeData, _: string, options: ICommonObject): Promise { + const credentialData = await getCredentialData(nodeData.credential ?? '', options) + const wolframAlphaAppId = getCredentialParam('wolframAlphaAppId', credentialData, nodeData) + return new WolframAlphaTool({ + appid: wolframAlphaAppId + }) + } +} + +module.exports = { nodeClass: WolframAlpha_Tools } diff --git a/packages/components/nodes/tools/WolframAlpha/wolframalpha.png b/packages/components/nodes/tools/WolframAlpha/wolframalpha.png new file mode 100644 index 000000000..77ef000be Binary files /dev/null and b/packages/components/nodes/tools/WolframAlpha/wolframalpha.png differ