cfd19e2b34
Adversarial review of the previous commit found a real regression it
introduced, reproduced against the actual code rather than inferred.
Changing _persist_active_ai_config from setdefault("configs", ...) to a
direct assignment made every backend switch write the whole in-memory
AI_CONFIGS over the settings file. Because AI_CONFIGS is now the built-in
defaults merged UNDER the file, that meant:
* an operator's hand edits were destroyed - and hand editing is the only
way to change cheap_model / temperature / max_tokens, since
set_active_model writes latest_model and there is no command for the rest,
* a config deliberately deleted from the file was re-seeded from the
defaults and written back, permanently,
* pinning a model for one provider silently reverted another provider's
entry,
* CONJURER_OLLAMA_MODEL stopped having any effect once the env-derived
block had been persisted once.
The original motivation was still valid (plain setdefault would drop a
pinned model), so the fix is narrower rather than a revert: persist ONLY
the field this process actually changed. _persist_active_ai_config takes
model_for and writes back just that config's latest_model; everything else
in the on-disk block is left exactly as found. The constants.py merge stays
- it is what keeps a newly added provider visible after an upgrade - and is
now in-memory only, so it cannot reach the file.
Tests: the disk-write path had ZERO coverage, which is precisely how this
got in. Added four tests that drive the real _persist_active_ai_config
against a temp settings file: the pin lands while operator edits survive and
a deleted config is not resurrected; a plain switch leaves the configs block
byte-identical; a pin survives a re-read; a corrupt file does not raise.
Verified they have teeth - reintroducing the regression fails two of them.
Also hardened two weak tests the review caught: the pin test asserted on the
object set_active_model returns, which IS the mutated dict (so it passed
regardless), and the unconfigured-endpoint test monkeypatched OLLAMACLIENT
to None when it was already None, passing vacuously.
Suite: 72 unit + 70 integration green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
69 lines
3.1 KiB
Bash
69 lines
3.1 KiB
Bash
# Copy to docker/env/bot.env and fill in. Do NOT commit the real file.
|
|
|
|
# --- Secrets ------------------------------------------------------------
|
|
# Option A: mount a netrc (recommended — covers discord/openai/anthropic/spotipy/youtube).
|
|
CONJURER_NETRC_FILE=/secrets/.netrc
|
|
# Option B: pass tokens directly (these take precedence over netrc).
|
|
# DISCORD_TOKEN=
|
|
# OPENAI_API_KEY=
|
|
# ANTHROPIC_API_KEY= # Claude backend; netrc machine 'anthropic' works too
|
|
# ASSEMBLYAI_API_KEY= # voice recognition; netrc machine 'assemblyai' works too
|
|
# YOUTUBE_USERNAME=
|
|
# YOUTUBE_PASSWORD=
|
|
|
|
# --- AI backend switch --------------------------------------------------
|
|
# Which AI config from system_gpt_settings.json is active at startup
|
|
# (e.g. "gpt", "claude" or "ollama"). Runtime switch:
|
|
# $gadaj_teraz <config> [model]. Unset = whatever the settings file's "active"
|
|
# key says, falling back to "gpt".
|
|
# CONJURER_AI_CONFIG=gpt
|
|
|
|
# --- Ollama (self-hosted models) ----------------------------------------
|
|
# The endpoint IS the whole configuration - no API key. Leave unset and the
|
|
# "ollama" backend simply refuses to be selected. In-cluster, use the Service
|
|
# DNS name; from outside, host:port. Port 11434 is Ollama's default.
|
|
# CONJURER_OLLAMA_URL=http://ollama.ollama.svc.cluster.local:11434
|
|
# CONJURER_OLLAMA_URL=
|
|
# DEFAULT model for normal replies. $modele_ai lists what the server actually
|
|
# has pulled. Pinning one at runtime with `$gadaj_teraz ollama <model>` is
|
|
# persisted into system_gpt_settings.json and from then on WINS over this
|
|
# variable - the pin is the more recent, more explicit choice. Clear the
|
|
# "latest_model" of the ollama entry in that file to fall back to this default.
|
|
# CONJURER_OLLAMA_MODEL=llama3.1:8b
|
|
# Model used for the cheaper MUSIC path; defaults to CONJURER_OLLAMA_MODEL.
|
|
# CONJURER_OLLAMA_CHEAP_MODEL=
|
|
# How long to wait for ANY backend to answer. 120s suits hosted APIs; a
|
|
# self-hosted model on a modest GPU may need more.
|
|
# CONJURER_AI_TIMEOUT_SECONDS=120
|
|
|
|
# --- Data ---------------------------------------------------------------
|
|
# Single mounted volume; all writable state is rooted here.
|
|
CONJURER_DATA_DIR=/data
|
|
|
|
# --- Flask comm layer (inbound from musician/librarian) -----------------
|
|
CONJURER_DISCORD_HOST=0.0.0.0
|
|
CONJURER_DISCORD_PORT=5000
|
|
|
|
# --- Internal service auth ----------------------------------------------
|
|
# Set the SAME value on bot + musician + librarian. Empty = auth disabled.
|
|
CONJURER_API_KEY=
|
|
|
|
# --- Where the bot reaches the other services (other Proxmox VMs) --------
|
|
CONJURER_FILE_SERVICE=http://MUSICIAN_VM_IP:5000
|
|
# Betoniarka (radio-operator API, runs in the radio container):
|
|
CONJURER_RADIO_SERVICE=http://RADIO_VM_IP:5005
|
|
# Liquidsoap harbor /skip (same radio container):
|
|
CONJURER_RADIO_HARBOR=http://RADIO_VM_IP:54321
|
|
CONJURER_LIBRARIAN_SERVICE=http://LIBRARIAN_VM_IP:5001
|
|
|
|
# --- Conan Exiles bridge (optional; empty/0 = disabled) -----------------
|
|
# CONAN_GM_ROLE_ID=0
|
|
# CONAN_RCON_HOST=
|
|
# CONAN_RCON_PORT=25575
|
|
# CONAN_RCON_PASSWORD=
|
|
# CONAN_CHAT_CHANNEL_ID=0
|
|
# CONAN_EVENTS_CHANNEL_ID=0
|
|
# CONAN_JOIN_CHANNEL_ID=0
|
|
# CONAN_LOG_MODE=local
|
|
# CONAN_LOG_PATH=
|