Spaces:
Sleeping
Sleeping
# FILE: modules/config_settings_public.py (Single Model, Guaranteed Launch) | |
import os | |
import sys | |
import logging | |
from huggingface_hub import hf_hub_download | |
logger = logging.getLogger("ZOTHEOS_Config") | |
if not logger.handlers: | |
handler = logging.StreamHandler(sys.stdout) | |
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - [%(funcName)s] - %(message)s') | |
handler.setFormatter(formatter) | |
logger.addHandler(handler) | |
logger.setLevel(logging.INFO) | |
IS_WEB_MODE = os.path.exists("/home/user/app") | |
# --- β β β USING ONLY ONE, VERIFIED MODEL TO GUARANTEE LAUNCH β β β --- | |
MODEL_DEFINITIONS = { | |
"mistral": { | |
"repo_id": "TheBloke/Mistral-7B-Instruct-v0.2-GGUF", | |
"filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf" | |
} | |
} | |
MODEL_PATHS = {} | |
if IS_WEB_MODE: | |
logger.info("β β β RUNNING IN WEB MODE (Hugging Face Space) β β β ") | |
N_GPU_LAYERS_FALLBACK = 0 | |
for name, model_info in MODEL_DEFINITIONS.items(): | |
logger.info(f"Downloading model: {name} from repo: {model_info['repo_id']}") | |
try: | |
MODEL_PATHS[name] = hf_hub_download(repo_id=model_info["repo_id"], filename=model_info["filename"]) | |
logger.info(f"β Successfully downloaded {name}.") | |
except Exception as e: | |
logger.error(f"β FAILED to download model {name}. Error: {e}") | |
raise e | |
else: # LOCAL MODE | |
logger.info("β β β RUNNING IN LOCAL MODE (Desktop/PC) β β β ") | |
APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | |
BASE_MODELS_DIR = os.path.join(APP_DIR, "models") | |
for name, model_info in MODEL_DEFINITIONS.items(): | |
MODEL_PATHS[name] = os.path.join(BASE_MODELS_DIR, model_info["filename"]) | |
N_GPU_LAYERS_FALLBACK = -1 | |
# --- Shared Configurations (Simplified) --- | |
MAX_CONCURRENT_MODELS = 1 # Only one model | |
N_CTX_FALLBACK = 2048 | |
VERBOSE_LLAMA_CPP = True | |
MODEL_SPECIFIC_PARAMS = { | |
"_default": { | |
"n_gpu_layers": N_GPU_LAYERS_FALLBACK, "n_ctx": N_CTX_FALLBACK, "f16_kv": True, | |
"use_mmap": True, "verbose": VERBOSE_LLAMA_CPP | |
}, | |
"mistral": {"chat_format": "mistral-instruct"} | |
} | |
INFERENCE_PRESETS = { "balanced": {"temperature": 0.7, "top_p": 0.9, "max_tokens": 1024} } | |
DEFAULT_INFERENCE_PRESET = "balanced" | |
DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity." | |
MODEL_ROLES = {"mistral": "analyst"} | |
MODEL_ROLE_SYSTEM_PROMPTS = {"analyst": "You are an impartial analyst.", "general": DEFAULT_SYSTEM_PROMPT} | |
ZOTHEOS_VERSION = "2.4 (Live - Single Model)" | |
logger.info(f"Config loaded. Version: {ZOTHEOS_VERSION}, Web Mode: {IS_WEB_MODE}") |