Add max iterations
This commit is contained in:
@@ -14,6 +14,7 @@ import { WakeLock } from './wakelock.js';
|
||||
|
||||
const STREAM_ENDPOINT = '/v1/chat/voice/stream';
|
||||
const SYSTEM_MESSAGE_KEY = 'odidere_system_message';
|
||||
const MAX_TURNS_KEY = 'odidere_max_turns';
|
||||
const ICONS_URL = '/static/icons.svg';
|
||||
|
||||
const StreamEventDelta = 'delta';
|
||||
@@ -102,6 +103,13 @@ class Odidere {
|
||||
this.$settingsClose = document.getElementById('settings-close');
|
||||
this.$settingsTabs = document.querySelectorAll('.settings-tab');
|
||||
this.$saveSystemMessage = document.getElementById('save-system-message');
|
||||
this.$composeSettingsOverlay = document.getElementById(
|
||||
'compose-settings-overlay',
|
||||
);
|
||||
this.$composeSettingsClose = document.getElementById(
|
||||
'compose-settings-close',
|
||||
);
|
||||
this.$maxTurnsInput = document.getElementById('max-turns-input');
|
||||
this.$compose = document.querySelector('.compose');
|
||||
|
||||
this.init();
|
||||
@@ -241,6 +249,18 @@ class Odidere {
|
||||
this.settings.saveSystemMessage(),
|
||||
);
|
||||
|
||||
// --- Compose settings ---
|
||||
this.$composeSettingsClose.addEventListener('click', () =>
|
||||
this._closeComposeSettings(),
|
||||
);
|
||||
this.$composeSettingsOverlay.addEventListener('click', (e) => {
|
||||
if (e.target === this.$composeSettingsOverlay)
|
||||
this._closeComposeSettings();
|
||||
});
|
||||
this.$maxTurnsInput.addEventListener('input', () => {
|
||||
this._setMaxTurns(this.$maxTurnsInput.value);
|
||||
});
|
||||
|
||||
// --- Model/voice change persistence ---
|
||||
this.settings.$model.addEventListener('change', () =>
|
||||
this.settings.saveModelSelection(),
|
||||
@@ -297,6 +317,9 @@ class Odidere {
|
||||
case 'settings':
|
||||
this.settings.open();
|
||||
break;
|
||||
case 'compose-settings':
|
||||
this._openComposeSettings();
|
||||
break;
|
||||
case 'attach':
|
||||
// Handled by direct listener on $attach.
|
||||
break;
|
||||
@@ -599,6 +622,10 @@ class Odidere {
|
||||
if (systemMessage) {
|
||||
payload.system_message = systemMessage;
|
||||
}
|
||||
const maxTurns = this._getMaxTurns();
|
||||
if (maxTurns > 0) {
|
||||
payload.max_iterations = maxTurns;
|
||||
}
|
||||
|
||||
// Clear attachments and location after building payload.
|
||||
this.clearAttachments();
|
||||
@@ -1100,6 +1127,30 @@ class Odidere {
|
||||
this.$location.classList.remove('compose__action-btn--location', 'active');
|
||||
}
|
||||
|
||||
// ====================
|
||||
// COMPOSE SETTINGS
|
||||
// ====================
|
||||
|
||||
_openComposeSettings() {
|
||||
this.$maxTurnsInput.value = this._getMaxTurns();
|
||||
this.$composeSettingsOverlay.classList.add('open');
|
||||
this.$composeSettingsClose.focus();
|
||||
}
|
||||
|
||||
_closeComposeSettings() {
|
||||
this.$composeSettingsOverlay.classList.remove('open');
|
||||
this.$composeSettings.focus();
|
||||
}
|
||||
|
||||
_getMaxTurns() {
|
||||
const stored = localStorage.getItem(MAX_TURNS_KEY);
|
||||
return stored ? Number(stored) : 0;
|
||||
}
|
||||
|
||||
_setMaxTurns(value) {
|
||||
localStorage.setItem(MAX_TURNS_KEY, String(value));
|
||||
}
|
||||
|
||||
// ====================
|
||||
// TWO-PRESS SAFETY PATTERNS
|
||||
// ====================
|
||||
|
||||
Reference in New Issue
Block a user