UNPKG

@n8n/n8n-nodes-langchain

Version:

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

71 lines 2.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LmChatOllama = void 0; const ollama_1 = require("@langchain/ollama"); const ai_utilities_1 = require("@n8n/ai-utilities"); const n8n_workflow_1 = require("n8n-workflow"); const description_1 = require("../LMOllama/description"); class LmChatOllama { constructor() { this.description = { displayName: 'Ollama Chat Model', name: 'lmChatOllama', icon: 'file:ollama.svg', group: ['transform'], version: 1, description: 'Language Model Ollama', defaults: { name: 'Ollama Chat Model', }, codex: { categories: ['AI'], subcategories: { AI: ['Language Models', 'Root Nodes'], 'Language Models': ['Chat Models (Recommended)'], }, resources: { primaryDocumentation: [ { url: 'https://docs.n8n.io/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.lmchatollama/', }, ], }, }, 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 modelName = this.getNodeParameter('model', itemIndex); const options = this.getNodeParameter('options', itemIndex, {}); const headers = credentials.apiKey ? { Authorization: `Bearer ${credentials.apiKey}`, } : undefined; const fetchWithTimeout = async (input, init) => await (0, ai_utilities_1.proxyFetch)(input, init, {}); const model = new ollama_1.ChatOllama({ ...options, baseUrl: credentials.baseUrl, model: modelName, format: options.format === 'default' ? undefined : options.format, callbacks: [new ai_utilities_1.N8nLlmTracing(this)], onFailedAttempt: (0, ai_utilities_1.makeN8nLlmFailedAttemptHandler)(this), headers, fetch: fetchWithTimeout, }); return { response: model, }; } } exports.LmChatOllama = LmChatOllama; //# sourceMappingURL=LmChatOllama.node.js.map