UNPKG

@n8n/n8n-nodes-langchain

Version:

![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)

131 lines 4.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ToolSearXng = void 0; const searxng_search_1 = require("@langchain/community/tools/searxng_search"); const n8n_workflow_1 = require("n8n-workflow"); const ai_utilities_1 = require("@n8n/ai-utilities"); async function getTool(ctx, itemIndex) { const credentials = await ctx.getCredentials('searXngApi'); const options = ctx.getNodeParameter('options', itemIndex); return new searxng_search_1.SearxngSearch({ apiBase: credentials.apiUrl, headers: { Accept: 'application/json', }, params: options, }); } class ToolSearXng { constructor() { this.description = { displayName: 'SearXNG', name: 'toolSearXng', icon: 'file:searXng.svg', group: ['transform'], version: 1, description: 'Search in SearXNG', defaults: { name: 'SearXNG', }, codex: { categories: ['AI'], subcategories: { AI: ['Tools'], Tools: ['Other Tools'], }, resources: { primaryDocumentation: [ { url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.toolsearxng', }, ], }, }, inputs: [], outputs: [n8n_workflow_1.NodeConnectionTypes.AiTool], outputNames: ['Tool'], credentials: [ { name: 'searXngApi', required: true, }, ], properties: [ (0, ai_utilities_1.getConnectionHintNoticeField)([n8n_workflow_1.NodeConnectionTypes.AiAgent]), { displayName: 'Options', name: 'options', type: 'collection', placeholder: 'Add Option', default: {}, options: [ { displayName: 'Number of Results', name: 'numResults', type: 'number', default: 10, }, { displayName: 'Search Page Number', name: 'pageNumber', type: 'number', default: 1, }, { displayName: 'Language', name: 'language', type: 'string', default: 'en', description: 'Defines the language to use. It\'s a two-letter language code. (e.g., `en` for English, `es` for Spanish, or `fr` for French). Head to <a href="https://docs.searxng.org/user/search-syntax.html#select-language">SearXNG search syntax page</a> for more info.', }, { displayName: 'Safe Search', name: 'safesearch', type: 'options', options: [ { name: 'None', value: 0, }, { name: 'Moderate', value: 1, }, { name: 'Strict', value: 2, }, ], default: 0, description: 'Filter search results of engines which support safe search', }, ], }, ], }; } async supplyData(itemIndex) { return { response: (0, ai_utilities_1.logWrapper)(await getTool(this, itemIndex), this), }; } async execute() { const result = []; const input = this.getInputData(); for (let i = 0; i < input.length; i++) { const item = input[i]; const tool = await getTool(this, i); result.push({ json: { response: await tool.invoke(item.json), }, pairedItem: { item: i, }, }); } return [result]; } } exports.ToolSearXng = ToolSearXng; //# sourceMappingURL=ToolSearXng.node.js.map