Spaces:
Running
Running
Update modules/config_settings_public.py
Browse files
modules/config_settings_public.py
CHANGED
@@ -5,6 +5,7 @@ import sys
|
|
5 |
import logging
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
|
|
|
8 |
logger = logging.getLogger("ZOTHEOS_Config")
|
9 |
if not logger.handlers:
|
10 |
handler = logging.StreamHandler(sys.stdout)
|
@@ -13,16 +14,18 @@ if not logger.handlers:
|
|
13 |
logger.addHandler(handler)
|
14 |
logger.setLevel(logging.INFO)
|
15 |
|
|
|
16 |
IS_WEB_MODE = os.path.exists("/home/user/app")
|
|
|
17 |
|
18 |
-
# ---
|
19 |
MODEL_DEFINITIONS = {
|
20 |
"mistral": {
|
21 |
"repo_id": "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
|
22 |
"filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf"
|
23 |
},
|
24 |
"gemma": {
|
25 |
-
"repo_id": "TheBloke/
|
26 |
"filename": "gemma-2b-it.Q4_K_M.gguf"
|
27 |
},
|
28 |
"qwen": {
|
@@ -31,28 +34,27 @@ MODEL_DEFINITIONS = {
|
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
|
35 |
-
|
36 |
if IS_WEB_MODE:
|
37 |
logger.info("β
β
β
RUNNING IN WEB MODE (Hugging Face Space) β
β
β
")
|
38 |
N_GPU_LAYERS_FALLBACK = 0
|
39 |
-
for name,
|
40 |
-
logger.info(f"Downloading model: {name} from repo: {
|
41 |
try:
|
42 |
-
MODEL_PATHS[name] = hf_hub_download(repo_id=
|
43 |
logger.info(f"β
Successfully downloaded {name}.")
|
44 |
except Exception as e:
|
45 |
logger.error(f"β FAILED to download model {name}. Error: {e}")
|
46 |
raise e
|
47 |
-
else:
|
48 |
logger.info("β
β
β
RUNNING IN LOCAL MODE (Desktop/PC) β
β
β
")
|
49 |
APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
50 |
BASE_MODELS_DIR = os.path.join(APP_DIR, "models")
|
51 |
-
for name,
|
52 |
-
MODEL_PATHS[name] = os.path.join(BASE_MODELS_DIR,
|
53 |
N_GPU_LAYERS_FALLBACK = -1
|
54 |
|
55 |
-
# ---
|
56 |
MAX_RAM_MODELS_GB = 23.8
|
57 |
MAX_CONCURRENT_MODELS = 3
|
58 |
N_CTX_FALLBACK = 2048
|
@@ -60,8 +62,12 @@ VERBOSE_LLAMA_CPP = True
|
|
60 |
|
61 |
MODEL_SPECIFIC_PARAMS = {
|
62 |
"_default": {
|
63 |
-
"n_gpu_layers": N_GPU_LAYERS_FALLBACK,
|
64 |
-
"
|
|
|
|
|
|
|
|
|
65 |
},
|
66 |
"mistral": {"chat_format": "mistral-instruct"},
|
67 |
"gemma": {"chat_format": "gemma"},
|
@@ -75,6 +81,7 @@ INFERENCE_PRESETS = {
|
|
75 |
}
|
76 |
DEFAULT_INFERENCE_PRESET = "balanced"
|
77 |
|
|
|
78 |
DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity."
|
79 |
SYSTEM_PERSONAS = {
|
80 |
"default": DEFAULT_SYSTEM_PROMPT,
|
@@ -88,9 +95,10 @@ MODEL_ROLES = {"mistral": "analyst", "gemma": "humanist", "qwen": "skeptic"}
|
|
88 |
MODEL_ROLE_SYSTEM_PROMPTS = {
|
89 |
"analyst": "You are an impartial analyst. Focus on facts, clarity, and cause-effect logic. Provide structured, evidence-based reasoning.",
|
90 |
"humanist": "You are a human-centered assistant. Focus on emotion, empathy, ethical considerations, and the potential human impact or experience related to the query.",
|
91 |
-
"skeptic": "You are a critical evaluator and a respectful skeptic. Your role is to challenge assumptions, highlight potential risks, point out biases, and explore alternative or less obvious interpretations.
|
92 |
"general": DEFAULT_SYSTEM_PROMPT
|
93 |
}
|
94 |
|
|
|
95 |
ZOTHEOS_VERSION = "3.2 (True Fusion Verified)"
|
96 |
-
logger.info(f"Config loaded. Version: {ZOTHEOS_VERSION}, Web Mode: {IS_WEB_MODE}")
|
|
|
5 |
import logging
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
|
8 |
+
# --- β
Setup Logging ---
|
9 |
logger = logging.getLogger("ZOTHEOS_Config")
|
10 |
if not logger.handlers:
|
11 |
handler = logging.StreamHandler(sys.stdout)
|
|
|
14 |
logger.addHandler(handler)
|
15 |
logger.setLevel(logging.INFO)
|
16 |
|
17 |
+
# --- β
Web Mode Detection ---
|
18 |
IS_WEB_MODE = os.path.exists("/home/user/app")
|
19 |
+
MODEL_PATHS = {}
|
20 |
|
21 |
+
# --- β
Model Repositories (Verified 2025-06) ---
|
22 |
MODEL_DEFINITIONS = {
|
23 |
"mistral": {
|
24 |
"repo_id": "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
|
25 |
"filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf"
|
26 |
},
|
27 |
"gemma": {
|
28 |
+
"repo_id": "TheBloke/gemma-2b-it-GGUF",
|
29 |
"filename": "gemma-2b-it.Q4_K_M.gguf"
|
30 |
},
|
31 |
"qwen": {
|
|
|
34 |
}
|
35 |
}
|
36 |
|
37 |
+
# --- β
Resolve Model Paths ---
|
|
|
38 |
if IS_WEB_MODE:
|
39 |
logger.info("β
β
β
RUNNING IN WEB MODE (Hugging Face Space) β
β
β
")
|
40 |
N_GPU_LAYERS_FALLBACK = 0
|
41 |
+
for name, model in MODEL_DEFINITIONS.items():
|
42 |
+
logger.info(f"Downloading model: {name} from repo: {model['repo_id']}")
|
43 |
try:
|
44 |
+
MODEL_PATHS[name] = hf_hub_download(repo_id=model["repo_id"], filename=model["filename"])
|
45 |
logger.info(f"β
Successfully downloaded {name}.")
|
46 |
except Exception as e:
|
47 |
logger.error(f"β FAILED to download model {name}. Error: {e}")
|
48 |
raise e
|
49 |
+
else:
|
50 |
logger.info("β
β
β
RUNNING IN LOCAL MODE (Desktop/PC) β
β
β
")
|
51 |
APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
52 |
BASE_MODELS_DIR = os.path.join(APP_DIR, "models")
|
53 |
+
for name, model in MODEL_DEFINITIONS.items():
|
54 |
+
MODEL_PATHS[name] = os.path.join(BASE_MODELS_DIR, model["filename"])
|
55 |
N_GPU_LAYERS_FALLBACK = -1
|
56 |
|
57 |
+
# --- β
Shared Parameters ---
|
58 |
MAX_RAM_MODELS_GB = 23.8
|
59 |
MAX_CONCURRENT_MODELS = 3
|
60 |
N_CTX_FALLBACK = 2048
|
|
|
62 |
|
63 |
MODEL_SPECIFIC_PARAMS = {
|
64 |
"_default": {
|
65 |
+
"n_gpu_layers": N_GPU_LAYERS_FALLBACK,
|
66 |
+
"n_ctx": N_CTX_FALLBACK,
|
67 |
+
"f16_kv": True,
|
68 |
+
"use_mmap": True,
|
69 |
+
"use_mlock": False,
|
70 |
+
"verbose": VERBOSE_LLAMA_CPP
|
71 |
},
|
72 |
"mistral": {"chat_format": "mistral-instruct"},
|
73 |
"gemma": {"chat_format": "gemma"},
|
|
|
81 |
}
|
82 |
DEFAULT_INFERENCE_PRESET = "balanced"
|
83 |
|
84 |
+
# --- β
System Roles ---
|
85 |
DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity."
|
86 |
SYSTEM_PERSONAS = {
|
87 |
"default": DEFAULT_SYSTEM_PROMPT,
|
|
|
95 |
MODEL_ROLE_SYSTEM_PROMPTS = {
|
96 |
"analyst": "You are an impartial analyst. Focus on facts, clarity, and cause-effect logic. Provide structured, evidence-based reasoning.",
|
97 |
"humanist": "You are a human-centered assistant. Focus on emotion, empathy, ethical considerations, and the potential human impact or experience related to the query.",
|
98 |
+
"skeptic": "You are a critical evaluator and a respectful skeptic. Your role is to challenge assumptions, highlight potential risks, point out biases, and explore alternative or less obvious interpretations.",
|
99 |
"general": DEFAULT_SYSTEM_PROMPT
|
100 |
}
|
101 |
|
102 |
+
# --- β
Version Info ---
|
103 |
ZOTHEOS_VERSION = "3.2 (True Fusion Verified)"
|
104 |
+
logger.info(f"Config loaded. Version: {ZOTHEOS_VERSION}, Web Mode: {IS_WEB_MODE}")
|