Enhance Ollama class constructor to accept num_ctx parameter and include it in API request if greater than zero. see #351

This commit is contained in:
Mic 2025-04-22 00:06:00 +02:00
parent 71f5aaf6b2
commit fc7854bb69

View file

@ -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;