Files

45 lines
2.0 KiB
JavaScript
Raw Permalink Normal View History

// web/knobs.mjs -- the reasoning-effort ladder and its select.
2026-11-16 21:32:02 +00:00
//
// The per-run sampling knobs are retired (developer, 2026-11-18): params are
// per-turn and only hers -- the <mind> verb sets them for one turn,
// nothing stores them. Reasoning effort is a property of the model
// pick (there is no unset effort), so its select lives inside the
// model picks (widgets.mjs's modelsBox) and the provider selection
// (view-home's admin block), not a knob row. The ladder mirrors
// server/discovery.mjs's EFFORT_LEVELS (the web cannot import server
// runtime code); keep them in step.
2026-11-16 21:32:02 +00:00
//
// The old knobs' teaching surface -- what temperature means, what
// top_p does -- was prompt-side all along: invariants.md documents
// the mind verb, and the model answers with native JSON. The GM-side
// texts died with the rows; the four bounds live on in the server's
// mind-verb validator (server/loop.mjs, KNOB_BOUNDS).
2026-11-16 21:32:02 +00:00
import { el } from './dom.mjs';
2026-11-16 23:52:58 +00:00
// the reasoning-effort ladder -- mirrors server/discovery.mjs's
// EFFORT_LEVELS; keep them in step
export const EFFORT_LEVELS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
/** A select over the ladder. The '' option's label names what an
* absent choice means at the call site (the measured default in the
* model box, "pick a level" in the selection prompt) -- the caller
* owns the sentence, this builds the options.
* @param {?string} current the pre-selected level ('' when none)
* @param {string} unsetLabel the '' option's label
* @returns {HTMLSelectElement}
2026-11-16 21:32:02 +00:00
*/
export function effortSelect(current, unsetLabel) {
const sel = /** @type {HTMLSelectElement} */ (el('select'));
const unset = /** @type {HTMLOptionElement} */ (el('option', null, unsetLabel));
unset.value = '';
sel.appendChild(unset);
for (const lv of EFFORT_LEVELS) {
const o = /** @type {HTMLOptionElement} */ (el('option', null, lv));
o.value = lv;
sel.appendChild(o);
2026-11-16 21:32:02 +00:00
}
sel.value = EFFORT_LEVELS.includes(String(current)) ? String(current) : '';
return sel;
2026-11-16 21:32:02 +00:00
}