aboutsummaryrefslogtreecommitdiff
path: root/modules/core/ollama-manager.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-06-17 06:01:20 +0200
committerAgando <roduccomm@gmail.com>2026-06-17 06:01:20 +0200
commitcebacc27a48168e666679018f8e27156d12d4527 (patch)
treeb306d33b67b9d8c84bd9b9c16b1e91ee217628a6 /modules/core/ollama-manager.js
parent6aa24b976952a698c673d350977721b27193183d (diff)
auto: 2026-06-17_06:01 changes
Diffstat (limited to 'modules/core/ollama-manager.js')
-rw-r--r--modules/core/ollama-manager.js41
1 files changed, 38 insertions, 3 deletions
diff --git a/modules/core/ollama-manager.js b/modules/core/ollama-manager.js
index 253e319..2f14aa8 100644
--- a/modules/core/ollama-manager.js
+++ b/modules/core/ollama-manager.js
@@ -19,6 +19,8 @@ class OllamaManager {
this.validatorEnabled = localStorage.getItem('webx11_validator_enabled') === 'true';
this.validatorModel = localStorage.getItem('webx11_validator_model') || 'ministral-3:3b-cloud';
this.validatorEndpoint = localStorage.getItem('webx11_validator_endpoint') || '';
+ // --- Model Parameters (temperature, top_p, max_tokens, thinking) ---
+ this.modelParams = this._loadModelParams();
// Build fallback endpoints
this.fallbackEndpoints = [];
const origin = typeof window !== 'undefined' ? window.location.origin : '';
@@ -73,6 +75,28 @@ class OllamaManager {
this._setSecret('webx11_llm_providers', JSON.stringify(this.providers));
}
+ _loadModelParams() {
+ try {
+ const saved = localStorage.getItem('webx11_model_params');
+ if (saved) {
+ const parsed = JSON.parse(saved);
+ return {
+ temperature: parsed.temperature !== undefined ? parsed.temperature : 0.7,
+ top_p: parsed.top_p !== undefined ? parsed.top_p : 0.9,
+ max_tokens: parsed.max_tokens !== undefined ? parsed.max_tokens : 4096,
+ thinking: parsed.thinking || 'off'
+ };
+ }
+ } catch (e) {}
+ return { temperature: 0.7, top_p: 0.9, max_tokens: 4096, thinking: 'off' };
+ }
+
+ _saveModelParams() {
+ try {
+ localStorage.setItem('webx11_model_params', JSON.stringify(this.modelParams));
+ } catch (e) {}
+ }
+
_getSecret(key) {
if (typeof window !== 'undefined' && window.webx11_secretVault && typeof window.webx11_secretVault.decrypt === 'function') {
return window.webx11_secretVault.decrypt(key);
@@ -711,10 +735,21 @@ class OllamaManager {
messages: messages,
stream: false
};
+ // Apply model parameters (user-configured temperature, top_p, max_tokens, thinking)
+ if (this.modelParams) {
+ body.temperature = this.modelParams.temperature;
+ body.top_p = this.modelParams.top_p;
+ body.max_tokens = this.modelParams.max_tokens;
+ }
if (isDeepSeek) {
- body.temperature = 0.3;
- body.max_tokens = 4096;
+ // DeepSeek defaults: user params override hardcoded defaults
+ if (body.temperature === undefined) body.temperature = 0.3;
+ if (body.max_tokens === undefined) body.max_tokens = 4096;
body.stop = ['<|end|>'];
+ // DeepSeek thinking mode
+ if (this.modelParams && this.modelParams.thinking !== 'off') {
+ body.thinking = { type: this.modelParams.thinking };
+ }
}
if (tools && tools.length > 0) {
body.tools = tools;
@@ -800,7 +835,7 @@ class OllamaManager {
return {
message: { role: 'assistant', content: '' },
tool_calls: null,
- error: null
+ error: 'DeepSeek returned empty response after retry — model may be overloaded or context too long'
};
}