feat(web): cloud chat-model selector in Settings
Pick which OpenAI model answers on the Cloud backend (gpt-4o / -mini / 4.1 / 4.1-mini / o4-mini, or Default). Persisted in localStorage, sent as `model` in the chat request; respond() applies it only on the cloud backend (local/mi50 keep their fixed models). Reachable from desktop + mobile via Settings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -92,9 +92,10 @@ def create_app() -> FastAPI:
|
||||
backend = _backend_for(body.get("backend"))
|
||||
user_msg = _last_user_message(body.get("messages", []))
|
||||
|
||||
model_override = body.get("model") or None
|
||||
memory.ensure_session(session_id)
|
||||
try:
|
||||
reply = await asyncio.to_thread(chat.respond, session_id, user_msg, backend)
|
||||
reply = await asyncio.to_thread(chat.respond, session_id, user_msg, backend, model_override)
|
||||
except Exception as exc:
|
||||
logbus.log("error", "chat failed", session=session_id, error=str(exc))
|
||||
reply = f"[error] {exc}"
|
||||
|
||||
@@ -143,6 +143,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="settings-section" style="margin-top: 24px;">
|
||||
<h4>Chat Model (Cloud)</h4>
|
||||
<p class="settings-desc">Which OpenAI model answers on the Cloud backend. Tools (poker, equity, journaling) require Cloud.</p>
|
||||
<select id="cloudModel">
|
||||
<option value="">Default (gpt-4o)</option>
|
||||
<option value="gpt-4o">gpt-4o — best persona</option>
|
||||
<option value="gpt-4o-mini">gpt-4o-mini — cheap/fast</option>
|
||||
<option value="gpt-4.1">gpt-4.1</option>
|
||||
<option value="gpt-4.1-mini">gpt-4.1-mini</option>
|
||||
<option value="o4-mini">o4-mini — reasoning</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="settings-section" style="margin-top: 24px;">
|
||||
<h4>Session Management</h4>
|
||||
<p class="settings-desc">Manage your saved chat sessions:</p>
|
||||
@@ -283,6 +296,12 @@
|
||||
body.backend = backend;
|
||||
}
|
||||
|
||||
// Cloud chat-model override (ignored server-side unless backend is cloud)
|
||||
const cloudModel = localStorage.getItem("cloudModel");
|
||||
if (cloudModel) {
|
||||
body.model = cloudModel;
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await fetch(API_URL, {
|
||||
method: "POST",
|
||||
@@ -571,6 +590,10 @@
|
||||
const initialRadio = document.querySelector(`input[name="backend"][value="${savedBackend}"]`);
|
||||
if (initialRadio) initialRadio.checked = true;
|
||||
|
||||
// Restore saved cloud-model choice
|
||||
const savedModelSel = document.getElementById("cloudModel");
|
||||
if (savedModelSel) savedModelSel.value = localStorage.getItem("cloudModel") || "";
|
||||
|
||||
// Session management functions
|
||||
async function loadSessionList() {
|
||||
try {
|
||||
@@ -679,7 +702,11 @@
|
||||
const backendValue = selectedRadio ? selectedRadio.value : "local";
|
||||
|
||||
localStorage.setItem("standardModeBackend", backendValue);
|
||||
addMessage("system", `Backend changed to: ${backendValue}`);
|
||||
const modelSel = document.getElementById("cloudModel");
|
||||
const modelValue = modelSel ? modelSel.value : "";
|
||||
localStorage.setItem("cloudModel", modelValue);
|
||||
const modelLabel = modelValue || "default (gpt-4o)";
|
||||
addMessage("system", `Backend: ${backendValue} · cloud model: ${modelLabel}`);
|
||||
hideModal();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user