ZOTHEOS commited on
Commit
92f3987
Β·
verified Β·
1 Parent(s): 92bff3a

Update modules/config_settings_public.py

Browse files
Files changed (1) hide show
  1. modules/config_settings_public.py +36 -78
modules/config_settings_public.py CHANGED
@@ -1,4 +1,4 @@
1
- # FILE: modules/config_settings_public.py
2
 
3
  import os
4
  import sys
@@ -13,108 +13,66 @@ if not logger.handlers:
13
  logger.addHandler(handler)
14
  logger.setLevel(logging.INFO)
15
 
16
- # --- βœ… DETECT ENVIRONMENT MODE ---
17
- IS_WEB_MODE = os.path.exists("/home/user/app") # Hugging Face Spaces default working dir
18
-
19
- # --- βœ… VERIFIED MODEL SOURCES (WEB + LOCAL FRIENDLY) ---
20
  MODEL_DEFINITIONS = {
21
  "mistral": {
22
  "repo_id": "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
23
- "filename": "mistral-7b-instruct-v0.2.Q4_K_M.gguf"
24
  },
25
  "gemma": {
26
- "repo_id": "MaziyarPanahi/Gemma-2B-IT-GGUF", # βœ… Verified
27
- "filename": "gemma-2b-it.Q4_K_M.gguf"
28
  },
29
  "qwen": {
30
- "repo_id": "tensorblock/Qwen1.5-1.8B-Chat-GGUF", # βœ… Verified Alternative
31
- "filename": "Qwen1.5-1.8B-Chat-Q4_K_M.gguf"
32
  }
33
  }
34
 
35
  MODEL_PATHS = {}
36
 
37
- if IS_WEB_MODE:
38
- logger.info("βœ…βœ…βœ… RUNNING IN WEB MODE (Hugging Face Space) βœ…βœ…βœ…")
39
- N_GPU_LAYERS_FALLBACK = 0 # CPU-only
40
- for name, model_info in MODEL_DEFINITIONS.items():
41
- logger.info(f"Downloading model: {name} from {model_info['repo_id']}")
42
- try:
43
- MODEL_PATHS[name] = hf_hub_download(repo_id=model_info["repo_id"], filename=model_info["filename"])
44
- logger.info(f"βœ… Successfully downloaded {name}")
45
- except Exception as e:
46
- logger.error(f"❌ FAILED to download {name}: {e}")
47
- raise e
48
- else:
49
- logger.info("βœ…βœ…βœ… RUNNING IN LOCAL MODE (Desktop/PC) βœ…βœ…βœ…")
50
- APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
51
- BASE_MODELS_DIR = os.path.join(APP_DIR, "models")
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 # Use GPU fully
55
 
56
- # --- πŸ’Ύ RUNTIME PARAMETERS ---
57
- MAX_RAM_MODELS_GB = 23.8
58
- MAX_CONCURRENT_MODELS = 3
59
- N_CTX_FALLBACK = 2048
60
- VERBOSE_LLAMA_CPP = True
 
 
 
61
 
 
62
  MODEL_SPECIFIC_PARAMS = {
63
- "_default": {
64
- "n_gpu_layers": N_GPU_LAYERS_FALLBACK,
65
- "n_ctx": N_CTX_FALLBACK,
66
- "f16_kv": True,
67
- "use_mmap": True,
68
- "use_mlock": False,
69
- "verbose": VERBOSE_LLAMA_CPP
70
  },
71
  "mistral": { "chat_format": "mistral-instruct" },
72
  "gemma": { "chat_format": "gemma" },
73
  "qwen": { "chat_format": "chatml" }
74
  }
75
 
76
- # --- πŸŽ›οΈ PRESET INFERENCE MODES ---
77
  INFERENCE_PRESETS = {
78
- "balanced": {
79
- "temperature": 0.7, "top_p": 0.9, "top_k": 40,
80
- "repeat_penalty": 1.1, "max_tokens": 1024
81
- },
82
- "precise": {
83
- "temperature": 0.2, "top_p": 0.7, "top_k": 20,
84
- "repeat_penalty": 1.05, "max_tokens": 1536
85
- },
86
- "creative": {
87
- "temperature": 0.9, "top_p": 0.95, "top_k": 60,
88
- "repeat_penalty": 1.15, "max_tokens": 1024
89
- }
90
  }
91
  DEFAULT_INFERENCE_PRESET = "balanced"
92
 
93
- # --- 🧠 SYSTEM PROMPTS ---
94
- DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity. Be clear, respectful, and helpful."
95
-
96
- SYSTEM_PERSONAS = {
97
- "default": DEFAULT_SYSTEM_PROMPT,
98
- "helpful_assistant": "You are a helpful AI assistant.",
99
- "philosopher": "You are an AI philosopher. Explore topics with nuance.",
100
- "coder": "You are an expert AI developer. Provide clean code and explanations.",
101
- "concise_summarizer": "You are a precise summarizer. Respond with brevity and clarity."
102
- }
103
-
104
- # --- 🎭 MODEL ROLES FOR FUSION ---
105
- MODEL_ROLES = {
106
- "mistral": "analyst",
107
- "gemma": "humanist",
108
- "qwen": "skeptic"
109
- }
110
-
111
  MODEL_ROLE_SYSTEM_PROMPTS = {
112
- "analyst": "You are an impartial analyst. Provide structured, logical insights.",
113
- "humanist": "You are empathetic and people-focused. Consider the emotional and ethical impact.",
114
- "skeptic": "You are a respectful skeptic. Question assumptions and highlight risks.",
115
- "general": DEFAULT_SYSTEM_PROMPT
116
  }
117
 
118
- # --- ℹ️ VERSION TAG ---
119
- ZOTHEOS_VERSION = "Public Beta 3.2 (True Fusion Verified)"
120
- logger.info(f"βœ… Config loaded. Version: {ZOTHEOS_VERSION} | Web Mode: {IS_WEB_MODE}")
 
1
+ # FILE: modules/config_settings_public.py (Hugging Face Demo - AGI-Tier Upgrade)
2
 
3
  import os
4
  import sys
 
13
  logger.addHandler(handler)
14
  logger.setLevel(logging.INFO)
15
 
16
+ # --- βœ… WEB-OPTIMIZED MODEL SOURCES ---
17
+ # These models are smaller and faster, perfect for a CPU-based web demo.
 
 
18
  MODEL_DEFINITIONS = {
19
  "mistral": {
20
  "repo_id": "TheBloke/Mistral-7B-Instruct-v0.2-GGUF",
21
+ "filename": "mistral-7b-instruct-v0.2.Q2_K.gguf" # Using a smaller Q2_K quantization for speed
22
  },
23
  "gemma": {
24
+ "repo_id": "TheBloke/gemma-2b-it-GGUF",
25
+ "filename": "gemma-2b-it.Q4_K_M.gguf" # Using the 2B parameter version
26
  },
27
  "qwen": {
28
+ "repo_id": "TheBloke/Qwen1.5-1.8B-Chat-GGUF",
29
+ "filename": "qwen1.5-1.8b-chat.Q4_K_M.gguf" # Using the 1.8B parameter version
30
  }
31
  }
32
 
33
  MODEL_PATHS = {}
34
 
35
+ # This logic will only run when the code is on Hugging Face Spaces.
36
+ logger.info("βœ…βœ…βœ… RUNNING IN WEB DEMO MODE (Hugging Face Space) βœ…βœ…βœ…")
37
+ N_GPU_LAYERS_FALLBACK = 0 # Force CPU-only mode for Hugging Face free tier
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
+ for name, model_info in MODEL_DEFINITIONS.items():
40
+ logger.info(f"Downloading model for demo: {name} from {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 {name}: {e}")
46
+ raise e
47
 
48
+ # --- βœ… WEB-OPTIMIZED MODEL PARAMETERS ---
49
  MODEL_SPECIFIC_PARAMS = {
50
+ "_default": {
51
+ "n_gpu_layers": N_GPU_LAYERS_FALLBACK, # Ensures CPU usage
52
+ "n_ctx": 4096, # Smaller context window for lower RAM usage
53
+ "n_batch": 512, # Standard batch size for CPU
54
+ "verbose": True
 
 
55
  },
56
  "mistral": { "chat_format": "mistral-instruct" },
57
  "gemma": { "chat_format": "gemma" },
58
  "qwen": { "chat_format": "chatml" }
59
  }
60
 
61
+ # --- βœ… AGI-TIER INFERENCE PRESETS ---
62
  INFERENCE_PRESETS = {
63
+ "balanced": {"temperature": 0.7, "top_p": 0.9, "max_tokens": 1024, "repeat_penalty": 1.1 },
64
+ "precise": {"temperature": 0.2, "top_p": 0.7, "top_k": 20, "max_tokens": 1536, "repeat_penalty": 1.05 },
65
+ "creative": {"temperature": 0.9, "top_p": 0.95, "top_k": 60, "max_tokens": 1024, "repeat_penalty": 1.15 }
 
 
 
 
 
 
 
 
 
66
  }
67
  DEFAULT_INFERENCE_PRESET = "balanced"
68
 
69
+ # --- βœ… AGI-TIER MODEL ROLES AND PROMPTS ---
70
+ DEFAULT_SYSTEM_PROMPT = "You are ZOTHEOS, an ethical AI developed to help humanity. Be clear, respectful, and helpful. Respond only in English."
71
+ MODEL_ROLES = {"mistral": "analyst", "gemma": "humanist", "qwen": "skeptic"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  MODEL_ROLE_SYSTEM_PROMPTS = {
73
+ "analyst": "You are an impartial analyst. Provide structured, logical insights. Break down complex topics into clear, understandable points. Respond only in English.",
74
+ "humanist": "You are an empathetic and values-driven AI. Focus on the emotional, ethical, and societal impact. Consider the human element above all. Respond only in English.",
75
+ "skeptic": "You are a respectful but rigorous skeptic. Challenge the user's premise, identify potential risks, question assumptions, and explore alternative interpretations. Respond only in English.",
 
76
  }
77
 
78
+ logger.info("βœ… Hugging Face Demo Configuration Loaded Successfully.")