n8n/packages/@n8n/nodes-langchain/nodes/tools/ToolWolframAlpha/ToolWolframAlpha.node.ts
oleg 0f7ae3f50a
refactor: Update Langchain to 0.1.41 & add support for Claude 3 (#8825)
Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Michael Kret <michael.k@radency.com>
2024-03-07 11:36:36 +01:00

59 lines
1.7 KiB
TypeScript

/* eslint-disable n8n-nodes-base/node-dirname-against-convention */
import {
NodeConnectionType,
type IExecuteFunctions,
type INodeType,
type INodeTypeDescription,
type SupplyData,
} from 'n8n-workflow';
import { WolframAlphaTool } from '@langchain/community/tools/wolframalpha';
import { logWrapper } from '../../../utils/logWrapper';
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
export class ToolWolframAlpha implements INodeType {
description: INodeTypeDescription = {
displayName: 'Wolfram|Alpha',
name: 'toolWolframAlpha',
icon: 'file:wolfram-alpha.svg',
group: ['transform'],
version: 1,
description: "Connects to WolframAlpha's computational intelligence engine.",
defaults: {
name: 'Wolfram Alpha',
},
credentials: [
{
name: 'wolframAlphaApi',
required: true,
},
],
codex: {
categories: ['AI'],
subcategories: {
AI: ['Tools'],
},
resources: {
primaryDocumentation: [
{
url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolwolframalpha/',
},
],
},
},
// eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node
inputs: [],
// eslint-disable-next-line n8n-nodes-base/node-class-description-outputs-wrong
outputs: [NodeConnectionType.AiTool],
outputNames: ['Tool'],
properties: [getConnectionHintNoticeField([NodeConnectionType.AiAgent])],
};
async supplyData(this: IExecuteFunctions): Promise<SupplyData> {
const credentials = await this.getCredentials('wolframAlphaApi');
return {
response: logWrapper(new WolframAlphaTool({ appid: credentials.appId as string }), this),
};
}
}