Spaces:
Running
Running
Update modules/config_settings_public.py
Browse files
modules/config_settings_public.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1 |
-
# FILE: modules/config_settings_public.py (
|
2 |
|
3 |
import os
|
4 |
import sys
|
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,19 +13,17 @@ if not logger.handlers:
|
|
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 |
-
# ---
|
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": "
|
29 |
-
"filename": "gemma-2b-it.Q4_K_M.gguf"
|
30 |
},
|
31 |
"qwen": {
|
32 |
"repo_id": "TheBloke/Qwen1.5-1.8B-Chat-GGUF",
|
@@ -34,27 +31,28 @@ MODEL_DEFINITIONS = {
|
|
34 |
}
|
35 |
}
|
36 |
|
37 |
-
|
|
|
38 |
if IS_WEB_MODE:
|
39 |
logger.info("β
β
β
RUNNING IN WEB MODE (Hugging Face Space) β
β
β
")
|
40 |
N_GPU_LAYERS_FALLBACK = 0
|
41 |
-
for name,
|
42 |
-
logger.info(f"Downloading model: {name} from repo: {
|
43 |
try:
|
44 |
-
MODEL_PATHS[name] = hf_hub_download(repo_id=
|
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,
|
54 |
-
MODEL_PATHS[name] = os.path.join(BASE_MODELS_DIR,
|
55 |
N_GPU_LAYERS_FALLBACK = -1
|
56 |
|
57 |
-
# ---
|
58 |
MAX_RAM_MODELS_GB = 23.8
|
59 |
MAX_CONCURRENT_MODELS = 3
|
60 |
N_CTX_FALLBACK = 2048
|
@@ -66,7 +64,6 @@ MODEL_SPECIFIC_PARAMS = {
|
|
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"},
|
@@ -75,13 +72,30 @@ MODEL_SPECIFIC_PARAMS = {
|
|
75 |
}
|
76 |
|
77 |
INFERENCE_PRESETS = {
|
78 |
-
"balanced": {
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
@@ -91,14 +105,17 @@ SYSTEM_PERSONAS = {
|
|
91 |
"concise_summarizer": "You are an AI tasked with providing very concise summaries."
|
92 |
}
|
93 |
|
94 |
-
MODEL_ROLES = {
|
|
|
|
|
|
|
|
|
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}")
|
|
|
1 |
+
# FILE: modules/config_settings_public.py (Updated Configuration)
|
2 |
|
3 |
import os
|
4 |
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 |
logger.addHandler(handler)
|
14 |
logger.setLevel(logging.INFO)
|
15 |
|
|
|
16 |
IS_WEB_MODE = os.path.exists("/home/user/app")
|
|
|
17 |
|
18 |
+
# --- β
β
β
100% VERIFIED REPOSITORY AND FILENAMES FOR ALL 3 MODELS β
β
β
---
|
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": "MaziyarPanahi/gemma-2b-it-GGUF", # Updated repo ID
|
26 |
+
"filename": "gemma-2b-it-GGUF.Q4_K_M.gguf" # Updated filename
|
27 |
},
|
28 |
"qwen": {
|
29 |
"repo_id": "TheBloke/Qwen1.5-1.8B-Chat-GGUF",
|
|
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
MODEL_PATHS = {}
|
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, model_info in MODEL_DEFINITIONS.items():
|
40 |
+
logger.info(f"Downloading model: {name} from repo: {model_info['repo_id']}")
|
41 |
try:
|
42 |
+
MODEL_PATHS[name] = hf_hub_download(repo_id=model_info["repo_id"], filename=model_info["filename"])
|
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: # LOCAL MODE
|
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, model_info in MODEL_DEFINITIONS.items():
|
52 |
+
MODEL_PATHS[name] = os.path.join(BASE_MODELS_DIR, model_info["filename"])
|
53 |
N_GPU_LAYERS_FALLBACK = -1
|
54 |
|
55 |
+
# --- Full-Featured Configurations ---
|
56 |
MAX_RAM_MODELS_GB = 23.8
|
57 |
MAX_CONCURRENT_MODELS = 3
|
58 |
N_CTX_FALLBACK = 2048
|
|
|
64 |
"n_ctx": N_CTX_FALLBACK,
|
65 |
"f16_kv": True,
|
66 |
"use_mmap": True,
|
|
|
67 |
"verbose": VERBOSE_LLAMA_CPP
|
68 |
},
|
69 |
"mistral": {"chat_format": "mistral-instruct"},
|
|
|
72 |
}
|
73 |
|
74 |
INFERENCE_PRESETS = {
|
75 |
+
"balanced": {
|
76 |
+
"temperature": 0.7,
|
77 |
+
"top_p": 0.9,
|
78 |
+
"top_k": 40,
|
79 |
+
"repeat_penalty": 1.1,
|
80 |
+
"max_tokens": 1024
|
81 |
+
},
|
82 |
+
"precise": {
|
83 |
+
"temperature": 0.2,
|
84 |
+
"top_p": 0.7,
|
85 |
+
"top_k": 20,
|
86 |
+
"repeat_penalty": 1.05,
|
87 |
+
"max_tokens": 1536
|
88 |
+
},
|
89 |
+
"creative": {
|
90 |
+
"temperature": 0.9,
|
91 |
+
"top_p": 0.95,
|
92 |
+
"top_k": 60,
|
93 |
+
"repeat_penalty": 1.15,
|
94 |
+
"max_tokens": 1024
|
95 |
+
}
|
96 |
}
|
97 |
DEFAULT_INFERENCE_PRESET = "balanced"
|
98 |
|
|
|
99 |
DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity."
|
100 |
SYSTEM_PERSONAS = {
|
101 |
"default": DEFAULT_SYSTEM_PROMPT,
|
|
|
105 |
"concise_summarizer": "You are an AI tasked with providing very concise summaries."
|
106 |
}
|
107 |
|
108 |
+
MODEL_ROLES = {
|
109 |
+
"mistral": "analyst",
|
110 |
+
"gemma": "humanist",
|
111 |
+
"qwen": "skeptic"
|
112 |
+
}
|
113 |
MODEL_ROLE_SYSTEM_PROMPTS = {
|
114 |
"analyst": "You are an impartial analyst. Focus on facts, clarity, and cause-effect logic. Provide structured, evidence-based reasoning.",
|
115 |
"humanist": "You are a human-centered assistant. Focus on emotion, empathy, ethical considerations, and the potential human impact or experience related to the query.",
|
116 |
+
"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. Question the premises if necessary.",
|
117 |
"general": DEFAULT_SYSTEM_PROMPT
|
118 |
}
|
119 |
|
|
|
120 |
ZOTHEOS_VERSION = "3.2 (True Fusion Verified)"
|
121 |
logger.info(f"Config loaded. Version: {ZOTHEOS_VERSION}, Web Mode: {IS_WEB_MODE}")
|