diff --git a/bot/config.py b/bot/config.py index 7f137e1..38b135e 100644 --- a/bot/config.py +++ b/bot/config.py @@ -7,8 +7,8 @@ Uses Pydantic for type-safe configuration loading from: import os from pathlib import Path -from typing import Any, Optional -from pydantic import BaseModel, Field, field_validator +from typing import Optional +from pydantic import BaseModel, Field from pydantic_settings import BaseSettings, SettingsConfigDict # ============================================ @@ -175,60 +175,9 @@ CONFIG = load_config() SECRETS = load_secrets() # ============================================ -# Config Manager Integration +# Re-exports for modules that import from config # ============================================ -# Import config_manager for unified configuration with Web UI support -try: - from config_manager import config_manager - HAS_CONFIG_MANAGER = True -except ImportError: - # Fallback if config_manager is not yet imported - HAS_CONFIG_MANAGER = False - config_manager = None - -# ============================================ -# Backward Compatibility Globals -# ============================================ -# These provide a transition path from globals.py to config.py -# These now support runtime overrides via config_manager -# TODO: Gradually migrate all code to use CONFIG/SECRETS directly - -# Legacy globals (for backward compatibility) -# These now support runtime overrides via config_manager - -def _get_config_value(static_value: Any, key_path: str, default: Any = None) -> Any: - """Get configuration value with config_manager fallback.""" - if HAS_CONFIG_MANAGER and config_manager: - runtime_value = config_manager.get(key_path) - return runtime_value if runtime_value is not None else static_value - return static_value - -def _get_config_state(static_value: Any, state_key: str) -> Any: - """Get configuration state from config_manager.""" - if HAS_CONFIG_MANAGER and config_manager: - state_value = config_manager.get_state(state_key) - return state_value if state_value is not None else static_value - return static_value - -# Service URLs -DISCORD_BOT_TOKEN = SECRETS.discord_bot_token -CHESHIRE_CAT_API_KEY = SECRETS.cheshire_cat_api_key -CHESHIRE_CAT_URL = _get_config_value(CONFIG.cheshire_cat.url, "services.cheshire_cat.url", "http://cheshire-cat:80") -USE_CHESHIRE_CAT = _get_config_value(CONFIG.cheshire_cat.enabled, "services.cheshire_cat.enabled", True) -CHESHIRE_CAT_TIMEOUT = _get_config_value(CONFIG.cheshire_cat.timeout_seconds, "services.cheshire_cat.timeout_seconds", 120) -LLAMA_URL = _get_config_value(CONFIG.services.url, "services.llama.url", "http://llama-swap:8080") -LLAMA_AMD_URL = _get_config_value(CONFIG.services.amd_url, "services.llama.amd_url", "http://llama-swap-amd:8080") -TEXT_MODEL = _get_config_value(CONFIG.models.text, "models.text", "llama3.1") -VISION_MODEL = _get_config_value(CONFIG.models.vision, "models.vision", "vision") -EVIL_TEXT_MODEL = _get_config_value(CONFIG.models.evil, "models.evil", "darkidol") -JAPANESE_TEXT_MODEL = _get_config_value(CONFIG.models.japanese, "models.japanese", "swallow") -OWNER_USER_ID = SECRETS.owner_user_id -AUTONOMOUS_DEBUG = _get_config_value(CONFIG.autonomous.debug_mode, "autonomous.debug_mode", False) -VOICE_DEBUG_MODE = _get_config_value(CONFIG.voice.debug_mode, "voice.debug_mode", False) -LANGUAGE_MODE = _get_config_value(CONFIG.discord.language_mode, "discord.language_mode", "english") -LOG_DIR = _get_config_value(CONFIG.memory.log_dir, "memory.log_dir", "/app/memory/logs") -PREFER_AMD_GPU = _get_config_value(CONFIG.gpu.prefer_amd, "gpu.prefer_amd", False) -AMD_MODELS_ENABLED = _get_config_value(CONFIG.gpu.amd_models_enabled, "gpu.amd_models_enabled", True) +# error_handler.py imports ERROR_WEBHOOK_URL from here ERROR_WEBHOOK_URL = SECRETS.error_webhook_url # ============================================