Spaces:
Running
Running
Update modules/config_settings_public.py
Browse files
modules/config_settings_public.py
CHANGED
@@ -13,10 +13,7 @@ if not logger.handlers:
|
|
13 |
logger.addHandler(handler)
|
14 |
logger.setLevel(logging.INFO)
|
15 |
|
16 |
-
# ---
|
17 |
-
# The environment variable might not be set at import time.
|
18 |
-
# A more reliable way is to check for the existence of the '/home/user/app' path,
|
19 |
-
# which is standard for Hugging Face Spaces.
|
20 |
IS_WEB_MODE = os.path.exists("/home/user/app")
|
21 |
|
22 |
# --- Define Model Repositories and Filenames ONCE ---
|
@@ -26,7 +23,7 @@ MODEL_DEFINITIONS = {
|
|
26 |
"filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf"
|
27 |
},
|
28 |
"gemma": {
|
29 |
-
"repo_id": "google/gemma-2b-it-gguf",
|
30 |
"filename": "gemma-2b-it.Q4_K_M.gguf"
|
31 |
},
|
32 |
"qwen": {
|
@@ -35,25 +32,46 @@ MODEL_DEFINITIONS = {
|
|
35 |
}
|
36 |
}
|
37 |
|
|
|
38 |
MODEL_PATHS = {}
|
39 |
|
|
|
40 |
if IS_WEB_MODE:
|
41 |
logger.info("β
β
β
RUNNING IN WEB MODE (Hugging Face Space) β
β
β
")
|
|
|
|
|
42 |
for name, model_info in MODEL_DEFINITIONS.items():
|
43 |
-
logger.info(f"Downloading model: {name}")
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
N_GPU_LAYERS_FALLBACK = 0
|
46 |
logger.info("N_GPU_LAYERS_FALLBACK forced to 0 for CPU-only web environment.")
|
|
|
47 |
else: # LOCAL MODE
|
48 |
logger.info("β
β
β
RUNNING IN LOCAL MODE (Desktop/PC) β
β
β
")
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
50 |
BASE_MODELS_DIR = os.path.join(APP_DIR, "models")
|
51 |
logger.info(f"Models will be loaded from local directory: {BASE_MODELS_DIR}")
|
|
|
52 |
for name, model_info in MODEL_DEFINITIONS.items():
|
53 |
MODEL_PATHS[name] = os.path.join(BASE_MODELS_DIR, model_info["filename"])
|
|
|
54 |
N_GPU_LAYERS_FALLBACK = -1
|
55 |
logger.info("N_GPU_LAYERS_FALLBACK set to -1 for local GPU acceleration.")
|
56 |
|
|
|
57 |
# --- Shared Configurations ---
|
58 |
MAX_RAM_MODELS_GB = 23.8
|
59 |
MAX_CONCURRENT_MODELS = 3
|
@@ -82,7 +100,7 @@ INFERENCE_PRESETS = {
|
|
82 |
}
|
83 |
DEFAULT_INFERENCE_PRESET = "balanced"
|
84 |
|
85 |
-
# ---
|
86 |
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."
|
87 |
|
88 |
SYSTEM_PERSONAS = {
|
@@ -93,6 +111,7 @@ SYSTEM_PERSONAS = {
|
|
93 |
"concise_summarizer": "You are an AI tasked with providing very concise summaries. Get straight to the point. Use bullet points where appropriate.",
|
94 |
}
|
95 |
|
|
|
96 |
MODEL_ROLES = {
|
97 |
"mistral": "analyst",
|
98 |
"gemma": "humanist",
|
@@ -107,6 +126,6 @@ MODEL_ROLE_SYSTEM_PROMPTS = {
|
|
107 |
}
|
108 |
|
109 |
# --- Version Info ---
|
110 |
-
ZOTHEOS_VERSION = "Public Beta 1.
|
111 |
logger.info(f"Config settings loaded. Version: {ZOTHEOS_VERSION}")
|
112 |
logger.info(f"Web Mode: {IS_WEB_MODE}")
|
|
|
13 |
logger.addHandler(handler)
|
14 |
logger.setLevel(logging.INFO)
|
15 |
|
16 |
+
# --- A more reliable way to detect if we are running in a Hugging Face Space ---
|
|
|
|
|
|
|
17 |
IS_WEB_MODE = os.path.exists("/home/user/app")
|
18 |
|
19 |
# --- Define Model Repositories and Filenames ONCE ---
|
|
|
23 |
"filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf"
|
24 |
},
|
25 |
"gemma": {
|
26 |
+
"repo_id": "google/gemma-2b-it-gguf", # Corrected from GGUF to gguf
|
27 |
"filename": "gemma-2b-it.Q4_K_M.gguf"
|
28 |
},
|
29 |
"qwen": {
|
|
|
32 |
}
|
33 |
}
|
34 |
|
35 |
+
# --- Initialize MODEL_PATHS dictionary ---
|
36 |
MODEL_PATHS = {}
|
37 |
|
38 |
+
# --- Set up paths and GPU layers based on environment ---
|
39 |
if IS_WEB_MODE:
|
40 |
logger.info("β
β
β
RUNNING IN WEB MODE (Hugging Face Space) β
β
β
")
|
41 |
+
logger.info("Model paths will be resolved by hf_hub_download.")
|
42 |
+
|
43 |
for name, model_info in MODEL_DEFINITIONS.items():
|
44 |
+
logger.info(f"Downloading model: {name} from repo: {model_info['repo_id']}")
|
45 |
+
try:
|
46 |
+
MODEL_PATHS[name] = hf_hub_download(repo_id=model_info["repo_id"], filename=model_info["filename"])
|
47 |
+
logger.info(f"Successfully downloaded {name}.")
|
48 |
+
except Exception as e:
|
49 |
+
logger.error(f"β FAILED to download model {name}. Error: {e}")
|
50 |
+
# To prevent the app from crashing, you might want to handle this gracefully
|
51 |
+
# For now, we'll let it raise the error so you see it in the logs.
|
52 |
+
raise e
|
53 |
+
|
54 |
N_GPU_LAYERS_FALLBACK = 0
|
55 |
logger.info("N_GPU_LAYERS_FALLBACK forced to 0 for CPU-only web environment.")
|
56 |
+
|
57 |
else: # LOCAL MODE
|
58 |
logger.info("β
β
β
RUNNING IN LOCAL MODE (Desktop/PC) β
β
β
")
|
59 |
+
_is_frozen = getattr(sys, 'frozen', False)
|
60 |
+
if _is_frozen:
|
61 |
+
APP_DIR = os.path.dirname(sys.executable)
|
62 |
+
else:
|
63 |
+
APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
64 |
+
|
65 |
BASE_MODELS_DIR = os.path.join(APP_DIR, "models")
|
66 |
logger.info(f"Models will be loaded from local directory: {BASE_MODELS_DIR}")
|
67 |
+
|
68 |
for name, model_info in MODEL_DEFINITIONS.items():
|
69 |
MODEL_PATHS[name] = os.path.join(BASE_MODELS_DIR, model_info["filename"])
|
70 |
+
|
71 |
N_GPU_LAYERS_FALLBACK = -1
|
72 |
logger.info("N_GPU_LAYERS_FALLBACK set to -1 for local GPU acceleration.")
|
73 |
|
74 |
+
|
75 |
# --- Shared Configurations ---
|
76 |
MAX_RAM_MODELS_GB = 23.8
|
77 |
MAX_CONCURRENT_MODELS = 3
|
|
|
100 |
}
|
101 |
DEFAULT_INFERENCE_PRESET = "balanced"
|
102 |
|
103 |
+
# --- System Prompts and Personas ---
|
104 |
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."
|
105 |
|
106 |
SYSTEM_PERSONAS = {
|
|
|
111 |
"concise_summarizer": "You are an AI tasked with providing very concise summaries. Get straight to the point. Use bullet points where appropriate.",
|
112 |
}
|
113 |
|
114 |
+
# --- Model Roles and System Prompts for TrueFusion ---
|
115 |
MODEL_ROLES = {
|
116 |
"mistral": "analyst",
|
117 |
"gemma": "humanist",
|
|
|
126 |
}
|
127 |
|
128 |
# --- Version Info ---
|
129 |
+
ZOTHEOS_VERSION = "Public Beta 1.7 (Web Live)"
|
130 |
logger.info(f"Config settings loaded. Version: {ZOTHEOS_VERSION}")
|
131 |
logger.info(f"Web Mode: {IS_WEB_MODE}")
|