diff options
| author | Agando <roduccomm@gmail.com> | 2026-06-18 06:00:40 +0200 |
|---|---|---|
| committer | Agando <roduccomm@gmail.com> | 2026-06-18 06:00:40 +0200 |
| commit | fba6df22dae297c89fa0df065628dddded66c69c (patch) | |
| tree | f954a04ee1effe56361282a16444deaa93bd0151 /modules/core/ollama-manager.js | |
| parent | a02db2f506dec15c0c89dd4f8f21f975f627e4fe (diff) | |
auto: 2026-06-18_06:00 changes
Diffstat (limited to 'modules/core/ollama-manager.js')
| -rw-r--r-- | modules/core/ollama-manager.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/modules/core/ollama-manager.js b/modules/core/ollama-manager.js index 2f14aa8..e3a3fdb 100644 --- a/modules/core/ollama-manager.js +++ b/modules/core/ollama-manager.js @@ -12,7 +12,7 @@ class OllamaManager { this.responseHooks = []; this._abortController = null; // --- AI Agent Loop Optimization Toggle --- - this.optimizationEnabled = localStorage.getItem('webx11_optimization_enabled') !== 'false'; + this.optimizationEnabled = localStorage.getItem('webx11_optimization_enabled') === 'true'; // v4.5.66: default OFF // --- Streaming Toggle --- this.streamEnabled = localStorage.getItem('webx11_stream_enabled') === 'true'; // --- Validator Agent Config --- @@ -345,6 +345,21 @@ class OllamaManager { return false; } + // v4.5.68: Fetch with timeout — wraps fetch() with AbortController to prevent network hangs + async fetchWithTimeout(url, options = {}, timeoutMs = 30000) { + const controller = new AbortController(); + const timer = setTimeout(() => controller.abort(), timeoutMs); + try { + const resp = await fetch(url, { ...options, signal: controller.signal }); + clearTimeout(timer); + return resp; + } catch (e) { + clearTimeout(timer); + if (e.name === 'AbortError') throw new Error(`Request timed out after ${timeoutMs / 1000}s`); + throw e; + } + } + // ─── Chat (non-streaming) ──────────────────────────────────────────────── async chat(prompt, model = null) { |