From 32911c07790b0cf2f7e2d9ff67ad5081184dbb67 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Sat, 19 Jul 2025 19:47:01 +0200 Subject: [PATCH] fix: assign to contextLength basellm getter --- core/llm/llms/HuggingFaceTGI.ts | 2 +- core/llm/llms/Ollama.ts | 2 +- core/llm/llms/Vllm.ts | 2 +- core/util/generateRepoMap.test.ts | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/llm/llms/HuggingFaceTGI.ts b/core/llm/llms/HuggingFaceTGI.ts index 8a86634c8..ca4acc6d9 100644 --- a/core/llm/llms/HuggingFaceTGI.ts +++ b/core/llm/llms/HuggingFaceTGI.ts @@ -25,7 +25,7 @@ class HuggingFaceTGI extends BaseLLM { } const json = await response.json(); this.model = json.model_id; - this.contextLength = Number.parseInt(json.max_input_length); + this._contextLength = Number.parseInt(json.max_input_length); }) .catch((e) => { console.log(`Failed to list models for HuggingFace TGI: ${e.message}`); diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 106f99e1b..a944f90f9 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -184,7 +184,7 @@ class Ollama extends BaseLLM implements ModelInstaller { let value = parts[2]; switch (key) { case "num_ctx": - this.contextLength = + this._contextLength = options.contextLength ?? Number.parseInt(value); break; case "stop": diff --git a/core/llm/llms/Vllm.ts b/core/llm/llms/Vllm.ts index ac550f153..97bd936cb 100644 --- a/core/llm/llms/Vllm.ts +++ b/core/llm/llms/Vllm.ts @@ -72,7 +72,7 @@ class Vllm extends OpenAI { const json = await response.json(); const data = json.data[0]; this.model = data.id; - this.contextLength = Number.parseInt(data.max_model_len); + this._contextLength = Number.parseInt(data.max_model_len); }) .catch((e) => { console.log(`Failed to list models for vLLM: ${e.message}`); diff --git a/core/util/generateRepoMap.test.ts b/core/util/generateRepoMap.test.ts index 78f879f63..67c58c6fd 100644 --- a/core/util/generateRepoMap.test.ts +++ b/core/util/generateRepoMap.test.ts @@ -55,7 +55,7 @@ describe.skip("generateRepoMap", () => { }); // Set testLLM properties - testLLM.contextLength = 2048; + testLLM._contextLength = 2048; testLLM.countTokens = jest.fn().mockReturnValue(10); // Act @@ -115,7 +115,7 @@ describe.skip("generateRepoMap", () => { }); // Set testLLM properties - testLLM.contextLength = 2048; + testLLM._contextLength = 2048; testLLM.countTokens = jest.fn().mockReturnValue(10); // Act @@ -184,7 +184,7 @@ describe.skip("generateRepoMap", () => { .mockImplementation(() => {}); // Set testLLM properties - testLLM.contextLength = 2048; + testLLM._contextLength = 2048; testLLM.countTokens = jest.fn().mockReturnValue(10); // Act