add wolframalpha tool
This commit is contained in:
parent
cf88b79927
commit
bcb24fb4b0
|
|
@ -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 <a target="_blank" href="https://developer.wolframalpha.com">Wolfram Alpha Portal</a>'
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'App ID',
|
||||||
|
name: 'wolframAlphaAppId',
|
||||||
|
type: 'password'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { credClass: WolframAlphaApp }
|
||||||
|
|
@ -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<any> {
|
||||||
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
|
const wolframAlphaAppId = getCredentialParam('wolframAlphaAppId', credentialData, nodeData)
|
||||||
|
return new WolframAlphaTool({
|
||||||
|
appid: wolframAlphaAppId
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { nodeClass: WolframAlpha_Tools }
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Loading…
Reference in New Issue