feat: web switch for her inner voice (Dolphin/3090 | Qwen-32B/MI50 | Off)

Her introspection (reflect/think) voice is now switchable live from the web
settings, read each cycle by the dream loop — so Brian can flip it off the 3090
before gaming without touching config or restarting.

- memory: runtime key/value settings table + get_setting/set_setting.
- self_state: INTROSPECTION_MODES (dolphin=local/dolphin3:8b, mi50=Qwen-32B,
  off=paused) + introspection_target()/set_introspection_mode(); default "dolphin".
  reflect() resolves from the live setting and SKIPS entirely when off.
- thoughts.think(): same resolution + skip-when-off.
- server: GET/POST /settings/introspection.
- index.html: "Inner Voice (introspection)" selector in Settings, applies instantly.
- tests: routing (dolphin/mi50), off-skip for think + reflect. Suite 77, ruff clean.

Default = Dolphin on the 3090 (richer voice). Flip to MI50 or Off in Settings
before gaming — that was the GPU-contention culprit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-22 19:16:35 +00:00
parent a705e573a9
commit a7966e4bab
7 changed files with 139 additions and 8 deletions
+22
View File
@@ -95,6 +95,12 @@ CREATE TABLE IF NOT EXISTS journal (
);
CREATE INDEX IF NOT EXISTS idx_journal_created ON journal(created_at);
-- Small runtime key/value settings (UI-tunable, read live by the dream loop).
CREATE TABLE IF NOT EXISTS settings (
key TEXT PRIMARY KEY,
value TEXT
);
-- Brian's behind-the-scenes feedback on Lyra's outputs (chat replies, reflections,
-- journal/metacognition). Stored as (context, content, rating) — the shape a future
-- fine-tune / preference dataset wants. One row per rated item (re-rating updates it).
@@ -639,6 +645,22 @@ def backfill_journal_embeddings(limit: int | None = None) -> int:
return n
def get_setting(key: str, default: str | None = None) -> str | None:
"""A runtime setting value (UI-tunable), or `default` if unset."""
r = _connection().execute("SELECT value FROM settings WHERE key = ?", (key,)).fetchone()
return r["value"] if r else default
def set_setting(key: str, value: str) -> None:
conn = _connection()
with conn:
conn.execute(
"INSERT INTO settings (key, value) VALUES (?, ?) "
"ON CONFLICT(key) DO UPDATE SET value = excluded.value",
(key, str(value)),
)
def add_rating(kind: str, rating: int, content: str, context: str | None = None,
ref: str | None = None, note: str | None = None) -> int:
"""Record (or replace) Brian's feedback on one Lyra output. One row per item: