From fc7854bb6962a9d2dd28734c817703634a1f83be Mon Sep 17 00:00:00 2001 From: Mic Date: Tue, 22 Apr 2025 00:06:00 +0200 Subject: [PATCH] Enhance Ollama class constructor to accept num_ctx parameter and include it in API request if greater than zero. see #351 --- js/api/ollama.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/api/ollama.js b/js/api/ollama.js index 0f300243..c08fc2e5 100644 --- a/js/api/ollama.js +++ b/js/api/ollama.js @@ -21,11 +21,13 @@ export class Ollama { host = ''; model = ''; stream = false; + num_ctx = 0; - constructor(host, model, stream = false) { + constructor(host, model, stream = false, num_ctx = 0) { this.host = host.trim().replace(/\/+$/, ""); this.model = model; this.stream = stream; + this.num_ctx = num_ctx; } fetchModels = async () => { @@ -78,6 +80,7 @@ export class Ollama { model: this.model, messages: messages, stream: this.stream, + ...(this.num_ctx > 0 ? { num_ctx: parseInt(this.num_ctx) } : {}) }), }); return response;