UNPKG

@n8n/n8n-nodes-langchain

Version:
77 lines 2.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LmOllama = void 0; const ollama_1 = require("@langchain/ollama"); const n8n_workflow_1 = require("n8n-workflow"); const description_1 = require("./description"); const ai_utilities_1 = require("@n8n/ai-utilities"); class LmOllama { constructor() { this.description = { displayName: 'Ollama Model', name: 'lmOllama', icon: 'file:ollama.svg', group: ['transform'], version: 1, description: 'Language Model Ollama', defaults: { name: 'Ollama Model', }, codex: { categories: ['AI'], subcategories: { AI: ['Language Models', 'Root Nodes'], 'Language Models': ['Text Completion Models'], }, resources: { primaryDocumentation: [ { url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmollama/', }, ], }, }, inputs: [], outputs: [n8n_workflow_1.NodeConnectionTypes.AiLanguageModel], outputNames: ['Model'], ...description_1.ollamaDescription, properties: [ (0, ai_utilities_1.getConnectionHintNoticeField)([n8n_workflow_1.NodeConnectionTypes.AiChain, n8n_workflow_1.NodeConnectionTypes.AiAgent]), description_1.ollamaModel, description_1.ollamaOptions, ], }; } async supplyData(itemIndex) { const credentials = await this.getCredentials('ollamaApi'); const baseUrl = credentials.baseUrl; (0, n8n_workflow_1.assertCredentialAllowsUrl)({ node: this.getNode(), credentialData: credentials, url: baseUrl, surface: 'Ollama', }); const modelName = this.getNodeParameter('model', itemIndex); const options = this.getNodeParameter('options', itemIndex, {}); const headers = credentials.apiKey ? { Authorization: `Bearer ${credentials.apiKey}`, } : undefined; const lookup = this.helpers.getSecureEgressFilter().createSecureLookup(); const model = new ollama_1.Ollama({ baseUrl, model: modelName, ...options, callbacks: [new ai_utilities_1.N8nLlmTracing(this)], onFailedAttempt: (0, ai_utilities_1.makeN8nLlmFailedAttemptHandler)(this), headers, fetch: async (input, init) => await (0, ai_utilities_1.proxyFetch)({ input, init, lookup }), }); return { response: model, }; } } exports.LmOllama = LmOllama; //# sourceMappingURL=LmOllama.node.js.map