Spaces:
Sleeping
Sleeping
File size: 5,279 Bytes
cafa3c5 ac35688 26e8bc9 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 0990d08 cafa3c5 ac35688 cafa3c5 dfce113 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 ac35688 cafa3c5 44b65e5 cafa3c5 44b65e5 cafa3c5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# FILE: modules/config_settings_public.py
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)
# --- β
FORCE WEB MODE ---
IS_WEB_MODE = True # π¨ Hugging Face Spaces override
_is_frozen = getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS')
if _is_frozen:
APP_DIR = os.path.dirname(sys.executable)
else:
try:
APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
except NameError:
APP_DIR = os.getcwd()
logger.warning(f"__file__ not defined, APP_DIR set to CWD: {APP_DIR}")
BASE_MODELS_DIR = os.path.join(APP_DIR, "models")
BASE_DATA_SUBDIR = "zotheos_public_data"
BASE_DATA_PATH = os.path.join(APP_DIR, BASE_DATA_SUBDIR)
CORE_DIRS_TO_VERIFY = {
"data_base": BASE_DATA_PATH,
"memory": os.path.join(BASE_DATA_PATH, "zotheos_memory"),
"cache": os.path.join(BASE_DATA_PATH, "cache"),
"cache_transformers": os.path.join(BASE_DATA_PATH, "cache", "transformers"),
"cache_huggingface": os.path.join(BASE_DATA_PATH, "cache", "huggingface"),
"cache_hf_hub": os.path.join(BASE_DATA_PATH, "cache", "huggingface", "hub"),
"logs": os.path.join(BASE_DATA_PATH, "logs"),
"temp": os.path.join(BASE_DATA_PATH, "temp_files"),
"models_root": BASE_MODELS_DIR
}
for dir_key, dir_path in CORE_DIRS_TO_VERIFY.items():
if dir_key == "models_root" and (_is_frozen or IS_WEB_MODE):
continue
os.makedirs(dir_path, exist_ok=True)
# --- β
MODEL PATHS CONFIG ---
if IS_WEB_MODE:
logger.info("β
β
β
RUNNING IN WEB MODE (Hugging Face Space) β
β
β
")
logger.info("Model paths will be resolved via hf_hub_download.")
MODEL_PATHS = {
"mistral": hf_hub_download(repo_id="TheBloke/Mistral-7B-Instruct-v0.2-GGUF", filename="mistral-7b-instruct-v0.2.Q4_K_M.gguf"),
"qwen": hf_hub_download(repo_id="Qwen/Qwen1.5-1.8B-Chat-GGUF", filename="qwen1.5-1.8b-chat.Q4_K_M.gguf")
}
N_GPU_LAYERS_FALLBACK = 0
logger.info("N_GPU_LAYERS_FALLBACK forced to 0 for web/CPU-only environment.")
else:
logger.info("β
β
β
RUNNING IN LOCAL MODE (Desktop) β
β
β
")
MODEL_PATHS = {
"mistral": os.path.join(BASE_MODELS_DIR, "mistral-7b-instruct-v0.2.Q4_K_M.gguf"),
"qwen": os.path.join(BASE_MODELS_DIR, "qwen1.5-1.8b-chat.Q4_K_M.gguf")
}
N_GPU_LAYERS_FALLBACK = -1
logger.info("N_GPU_LAYERS_FALLBACK set to -1 for local GPU acceleration.")
# --- β
UNIVERSAL SETTINGS ---
MAX_RAM_MODELS_GB = 23.8
MAX_CONCURRENT_MODELS = 3
N_CTX_FALLBACK = 2048
N_THREADS_FALLBACK = 8
VERBOSE_LLAMA_CPP = True
MODEL_SPECIFIC_PARAMS = {
"mistral": { "chat_format": "mistral-instruct", "n_ctx": N_CTX_FALLBACK },
"qwen": { "chat_format": "chatml", "n_ctx": N_CTX_FALLBACK },
"_default": {
"f16_kv": True, "use_mmap": True, "use_mlock": False,
"verbose": VERBOSE_LLAMA_CPP,
"n_gpu_layers": N_GPU_LAYERS_FALLBACK,
"n_threads": N_THREADS_FALLBACK,
"n_ctx": N_CTX_FALLBACK
}
}
INFERENCE_PRESETS = {
"balanced": {"temperature": 0.7, "top_p": 0.9, "top_k": 40, "repeat_penalty": 1.1, "mirostat_mode": 0, "max_tokens": 1024},
"precise": {"temperature": 0.2, "top_p": 0.7, "top_k": 20, "repeat_penalty": 1.05, "mirostat_mode": 0, "max_tokens": 1536},
"creative": {"temperature": 0.9, "top_p": 0.95, "top_k": 60, "repeat_penalty": 1.15, "mirostat_mode": 2, "mirostat_tau": 4.0, "mirostat_eta": 0.1, "max_tokens": 1024},
"passthrough": {}
}
DEFAULT_INFERENCE_PRESET = "balanced"
DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity. Provide clear, concise, and helpful responses. Be respectful and avoid harmful content."
SYSTEM_PERSONAS = {
"default": DEFAULT_SYSTEM_PROMPT,
"helpful_assistant": "You are a helpful AI assistant.",
"philosopher": "You are a philosopher. Engage deeply and explore ideas.",
"coder": "You are an expert AI developer. Provide great code and reasoning.",
"concise_summarizer": "Summarize in bullet points. Be concise."
}
MODEL_ROLES = {
"mistral": "analyst",
"qwen": "skeptic"
}
MODEL_ROLE_SYSTEM_PROMPTS = {
"analyst": "You are an impartial analyst. Focus on evidence and logic.",
"skeptic": "You are a respectful skeptic. Point out flaws and explore alternate views.",
"general": DEFAULT_SYSTEM_PROMPT
}
MODEL_WEIGHTS = {
"mistral": 1.0,
"qwen": 1.1
}
LOG_LEVEL = "INFO"
LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - [%(funcName)s] - %(message)s'
ENV_VARS_TO_SET = {
"TRANSFORMERS_CACHE": CORE_DIRS_TO_VERIFY["cache_transformers"],
"HF_HOME": CORE_DIRS_TO_VERIFY["cache_huggingface"],
"HF_HUB_CACHE": CORE_DIRS_TO_VERIFY["cache_hf_hub"],
"TOKENIZERS_PARALLELISM": "false"
}
ZOTHEOS_VERSION = "Public Beta 1.4 (Web Enabled)"
logger.info(f"Config settings loaded. Version: {ZOTHEOS_VERSION}")
logger.info(f"APP_DIR: {APP_DIR} (Frozen: {_is_frozen}) | Web Mode: {IS_WEB_MODE}")
|