@n8n/n8n-nodes-langchain
Version:

68 lines • 2.56 kB
JavaScript
;
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 modelName = this.getNodeParameter('model', itemIndex);
const options = this.getNodeParameter('options', itemIndex, {});
const headers = credentials.apiKey
? {
Authorization: `Bearer ${credentials.apiKey}`,
}
: undefined;
const model = new ollama_1.Ollama({
baseUrl: credentials.baseUrl,
model: modelName,
...options,
callbacks: [new ai_utilities_1.N8nLlmTracing(this)],
onFailedAttempt: (0, ai_utilities_1.makeN8nLlmFailedAttemptHandler)(this),
headers,
});
return {
response: model,
};
}
}
exports.LmOllama = LmOllama;
//# sourceMappingURL=LmOllama.node.js.map