Spaces:
Sleeping
Sleeping
File size: 4,280 Bytes
3324abf ac35688 9470356 40b123c 9470356 40b123c 9f05f25 9470356 9f05f25 9470356 40b123c ac35688 9f05f25 f728ad5 ac35688 9470356 f728ad5 3324abf 40b123c 9470356 40b123c 9470356 40b123c 3324abf 9470356 40b123c f728ad5 9470356 dfce113 9470356 de81947 9f05f25 ac35688 9f05f25 ac35688 157eef0 9470356 157eef0 40b123c 9470356 9f05f25 9470356 9f05f25 9470356 ac35688 78a6734 9470356 de81947 9470356 9f05f25 9470356 9f05f25 de81947 9470356 |
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 |
# 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)
# --- β
DETECT ENVIRONMENT MODE ---
IS_WEB_MODE = os.path.exists("/home/user/app") # Hugging Face Spaces default working dir
# --- β
VERIFIED MODEL SOURCES (WEB + LOCAL FRIENDLY) ---
MODEL_DEFINITIONS = {
"mistral": {
"repo_id": "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
"filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf"
},
"gemma": {
"repo_id": "MaziyarPanahi/Gemma-2B-IT-GGUF", # β
Verified
"filename": "gemma-2b-it.Q4_K_M.gguf"
},
"qwen": {
"repo_id": "tensorblock/Qwen1.5-1.8B-Chat-GGUF", # β
Verified Alternative
"filename": "Qwen1.5-1.8B-Chat-Q4_K_M.gguf"
}
}
MODEL_PATHS = {}
if IS_WEB_MODE:
logger.info("β
β
β
RUNNING IN WEB MODE (Hugging Face Space) β
β
β
")
N_GPU_LAYERS_FALLBACK = 0 # CPU-only
for name, model_info in MODEL_DEFINITIONS.items():
logger.info(f"Downloading model: {name} from {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 {name}: {e}")
raise e
else:
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 # Use GPU fully
# --- πΎ RUNTIME PARAMETERS ---
MAX_RAM_MODELS_GB = 23.8
MAX_CONCURRENT_MODELS = 3
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,
"use_mlock": False,
"verbose": VERBOSE_LLAMA_CPP
},
"mistral": { "chat_format": "mistral-instruct" },
"gemma": { "chat_format": "gemma" },
"qwen": { "chat_format": "chatml" }
}
# --- ποΈ PRESET INFERENCE MODES ---
INFERENCE_PRESETS = {
"balanced": {
"temperature": 0.7, "top_p": 0.9, "top_k": 40,
"repeat_penalty": 1.1, "max_tokens": 1024
},
"precise": {
"temperature": 0.2, "top_p": 0.7, "top_k": 20,
"repeat_penalty": 1.05, "max_tokens": 1536
},
"creative": {
"temperature": 0.9, "top_p": 0.95, "top_k": 60,
"repeat_penalty": 1.15, "max_tokens": 1024
}
}
DEFAULT_INFERENCE_PRESET = "balanced"
# --- π§ SYSTEM PROMPTS ---
DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity. Be clear, respectful, and helpful."
SYSTEM_PERSONAS = {
"default": DEFAULT_SYSTEM_PROMPT,
"helpful_assistant": "You are a helpful AI assistant.",
"philosopher": "You are an AI philosopher. Explore topics with nuance.",
"coder": "You are an expert AI developer. Provide clean code and explanations.",
"concise_summarizer": "You are a precise summarizer. Respond with brevity and clarity."
}
# --- π MODEL ROLES FOR FUSION ---
MODEL_ROLES = {
"mistral": "analyst",
"gemma": "humanist",
"qwen": "skeptic"
}
MODEL_ROLE_SYSTEM_PROMPTS = {
"analyst": "You are an impartial analyst. Provide structured, logical insights.",
"humanist": "You are empathetic and people-focused. Consider the emotional and ethical impact.",
"skeptic": "You are a respectful skeptic. Question assumptions and highlight risks.",
"general": DEFAULT_SYSTEM_PROMPT
}
# --- βΉοΈ VERSION TAG ---
ZOTHEOS_VERSION = "Public Beta 3.2 (True Fusion Verified)"
logger.info(f"β
Config loaded. Version: {ZOTHEOS_VERSION} | Web Mode: {IS_WEB_MODE}")
|