n8n/packages/@n8n/nodes-langchain/nodes/tools/ToolWikipedia/ToolWikipedia.node.ts
oleg 7806a65229
feat: Add option to returnIntermediateSteps for AI agents (#8113)
## Summary
![CleanShot 2023-12-21 at 08 30
16](https://github.com/n8n-io/n8n/assets/12657221/66b0de47-80cd-41f9-940e-6cacc2c940a9)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
2023-12-21 10:27:49 +01:00

56 lines
1.6 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 { WikipediaQueryRun } from 'langchain/tools';
import { logWrapper } from '../../../utils/logWrapper';
import { getConnectionHintNoticeField } from '../../../utils/sharedFields';
export class ToolWikipedia implements INodeType {
description: INodeTypeDescription = {
displayName: 'Wikipedia',
name: 'toolWikipedia',
icon: 'file:wikipedia.svg',
group: ['transform'],
version: 1,
description: 'Search in Wikipedia',
defaults: {
name: 'Wikipedia',
},
codex: {
categories: ['AI'],
subcategories: {
AI: ['Tools'],
},
resources: {
primaryDocumentation: [
{
url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolwikipedia/',
},
],
},
},
// 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 WikiTool = new WikipediaQueryRun();
WikiTool.description =
'A tool for interacting with and fetching data from the Wikipedia API. The input should always be a string query.';
return {
response: logWrapper(WikiTool, this),
};
}
}