Awesome-Developer commited on
Commit
048bd6d
·
verified ·
1 Parent(s): cc7fd33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -15,7 +15,7 @@ if TARGET_SITE_PATH not in sys.path:
15
  sys.path.insert(0, TARGET_SITE_PATH)
16
  site.addsitedir(TARGET_SITE_PATH)
17
 
18
- # Check and boot the persistent engine compiled in your previous run
19
  try:
20
  from llama_cpp import Llama
21
  print("🚀 Perfect! Pre-compiled engine found in /data. Loading instantly...")
@@ -34,7 +34,7 @@ import gradio as gr
34
  from huggingface_hub import hf_hub_download
35
  import spaces
36
 
37
- # 2. FIXED MODEL PATH MAPS (Bypasses the 404 Error)
38
  print("Checking persistent storage for AI model weights...")
39
 
40
  # Model 1: The Main 27B Monster for GPU (3.9 GB)
@@ -44,19 +44,19 @@ path_27b = hf_hub_download(
44
  local_dir="/data"
45
  )
46
 
47
- # Model 2: FIXED REPOSITORY PATH AND FILE LAYOUT
48
- # Changes repo to LiquidAI and filename to use dot quantization separation to fix the 404 crash!
49
  path_moe = hf_hub_download(
50
- repo_id="LiquidAI/LFM2.5-8B-A1B-GGUF",
51
- filename="LFM2.5-8B-A1B.Q4_K_M.gguf",
52
  local_dir="/data"
53
  )
54
 
55
- # Load the MoE model globally on the free CPU thread so it never falls asleep
56
  print("Initializing Liquid 8B MoE on active CPU thread...")
57
  llm_cpu = Llama(model_path=path_moe, n_ctx=4096, n_gpu_layers=0, verbose=False)
58
 
59
- # 3. ENDPOINT FUNCTION WORKFLOWS
60
  @spaces.GPU(duration=60)
61
  def generate_27b(prompt):
62
  clean_prompt = str(prompt).strip()
@@ -74,7 +74,7 @@ def generate_moe_cpu(prompt):
74
  clean_prompt = str(prompt).strip()
75
  if not clean_prompt: return "Empty prompt."
76
 
77
- # Liquid AI specific chat markers
78
  system_tool_prompt = "You are an advanced AI agent with Tool Calling capabilities."
79
  formatted = f"<|im_start|>system\n{system_tool_prompt}<|im_end|>\n<|im_start|>user\n{clean_prompt}<|im_end|>\n<|im_start|>assistant\n"
80
 
@@ -82,7 +82,7 @@ def generate_moe_cpu(prompt):
82
  try: return response["choices"]["text"]
83
  except: return str(response)
84
 
85
- # 4. GRADIO DUAL TAB REGISTRY
86
  with gr.Blocks(title="Resilient AI Hub") as demo:
87
  gr.Markdown("# 🌳 Unstoppable Split-Brain AI Hub")
88
 
 
15
  sys.path.insert(0, TARGET_SITE_PATH)
16
  site.addsitedir(TARGET_SITE_PATH)
17
 
18
+ # Pull the pre-compiled llama-cpp wheel built in your previous runtime pass
19
  try:
20
  from llama_cpp import Llama
21
  print("🚀 Perfect! Pre-compiled engine found in /data. Loading instantly...")
 
34
  from huggingface_hub import hf_hub_download
35
  import spaces
36
 
37
+ # 2. UPDATED MODEL WORKSPACE INDEXES (Uses your exact link maps!)
38
  print("Checking persistent storage for AI model weights...")
39
 
40
  # Model 1: The Main 27B Monster for GPU (3.9 GB)
 
44
  local_dir="/data"
45
  )
46
 
47
+ # Model 2: YOUR EXACT WORKING LINK SWAP
48
+ # Points precisely to the repo and file schema you provided to eliminate the 404 crash!
49
  path_moe = hf_hub_download(
50
+ repo_id="LiquidAI/LFM2-8B-A1B-GGUF",
51
+ filename="LFM2-8B-A1B-Q4_K_M.gguf",
52
  local_dir="/data"
53
  )
54
 
55
+ # Initialize the 8B MoE model to the unmetered CPU thread
56
  print("Initializing Liquid 8B MoE on active CPU thread...")
57
  llm_cpu = Llama(model_path=path_moe, n_ctx=4096, n_gpu_layers=0, verbose=False)
58
 
59
+ # 3. ENDPOINT Workflows
60
  @spaces.GPU(duration=60)
61
  def generate_27b(prompt):
62
  clean_prompt = str(prompt).strip()
 
74
  clean_prompt = str(prompt).strip()
75
  if not clean_prompt: return "Empty prompt."
76
 
77
+ # Liquid AI specific instruction tags
78
  system_tool_prompt = "You are an advanced AI agent with Tool Calling capabilities."
79
  formatted = f"<|im_start|>system\n{system_tool_prompt}<|im_end|>\n<|im_start|>user\n{clean_prompt}<|im_end|>\n<|im_start|>assistant\n"
80
 
 
82
  try: return response["choices"]["text"]
83
  except: return str(response)
84
 
85
+ # 4. GRADIO MULTI-TAB MAPPING DESIGN
86
  with gr.Blocks(title="Resilient AI Hub") as demo:
87
  gr.Markdown("# 🌳 Unstoppable Split-Brain AI Hub")
88