mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 13:34:40 +00:00
3d9d47aa90
Wire the bot's AI chat pipeline (ai_functions.handle_response) to talk to either OpenAI or the Anthropic Messages API, chosen by one active-config switch. Behaviour on the default "gpt" config is unchanged. constants.py: * guarded `import anthropic` + CLAUDECLIENT (mirrors OPENAICLIENT), netrc machine 'anthropic' / ANTHROPIC_API_KEY; * CLAUDE_LATEST_MODEL / CLAUDE_CHEAP_MODEL (opus-4-8 / haiku-4-5); * AI_CONFIGS + DEFAULT_AI_CONFIG loaded from an optional 3rd element of system_gpt_settings.json (backward compatible - a 2-element file falls back to built-in defaults, active "gpt"). Single switch: CONJURER_AI_CONFIG env > settings "active" > "gpt". ai_functions.py: * provider_generate() dispatches to OpenAI (unchanged openai_call) or the new _anthropic_call() (splits system out, alternating messages, max_tokens, temperature omitted - Opus 4.8 rejects sampling params); * AIError normalises both SDKs' exceptions into one category set so handle_response keeps its single set of in-character error replies; * select_model() reads the active config; legacy "gpt-4o" default auto-maps to the active provider's model so the switch actually changes the backend; * set_active_ai_config()/list_ai_configs() with best-effort persistence back into system_gpt_settings.json index 2. ai_commands.py: * $gadaj_teraz <config> hybrid command (Vykidailo-gated) switches backend at runtime; * graceful guards when OPENAICLIENT is None: personal assistants (OpenAI Assistants API) and DALL-E image gen degrade instead of crashing, so a Claude-only deployment boots. system_gpt_settings.json: add the configs block (gpt/claude/_template) as the collection point for future backends. requirements_bot.txt: add anthropic. bot.env.example: ANTHROPIC_API_KEY + CONJURER_AI_CONFIG. Unit tests cover the message splitter, model selection, config listing, and error mapping. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
50 lines
2.0 KiB
Bash
50 lines
2.0 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" or "claude"). Runtime switch: $gadaj_teraz <config>. Unset =
|
|
# whatever the settings file's "active" key says, falling back to "gpt".
|
|
# CONJURER_AI_CONFIG=gpt
|
|
|
|
# --- 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=
|