From 8c64af43417b87886a1f101eacefd6934a2f13f0 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Wed, 1 Oct 2025 12:07:25 -0700 Subject: [PATCH 1/5] auto model context limit detection for ollama llm provider --- .../LLMSelection/OllamaLLMOptions/index.jsx | 52 +++++++------ server/models/systemSettings.js | 2 +- server/utils/AiProviders/ollama/index.js | 75 ++++++++++++++++--- server/utils/helpers/updateENV.js | 2 +- 4 files changed, 94 insertions(+), 37 deletions(-) diff --git a/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx b/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx index 0721dfa8d1a..67367c7f625 100644 --- a/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx +++ b/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx @@ -25,7 +25,7 @@ export default function OllamaLLMOptions({ settings }) { settings?.OllamaLLMPerformanceMode || "base" ); const [maxTokens, setMaxTokens] = useState( - settings?.OllamaLLMTokenLimit || 4096 + settings?.OllamaLLMTokenLimit || "" ); return ( @@ -36,27 +36,6 @@ export default function OllamaLLMOptions({ settings }) { basePath={basePath.value} authToken={authToken.value} /> -
- - setMaxTokens(Number(e.target.value))} - onScroll={(e) => e.target.blur()} - required={true} - autoComplete="off" - /> -

- Maximum number of tokens for context and response. -

-
+
+ + + setMaxTokens(e.target.value ? Number(e.target.value) : "") + } + onScroll={(e) => e.target.blur()} + required={false} + autoComplete="off" + /> +

+ Override the context window limit. Leave empty to auto-detect + from the model (defaults to 4096 if detection fails). +

+
+
+
@@ -160,7 +160,7 @@ function LMStudioModelSelection({ settings, basePath = null }) { findCustomModels(); }, [basePath]); - if (loading || customModels.length == 0) { + if (loading || customModels.length === 0) { return (