PoetNameLife commited on
Commit
cc71b6e
·
verified ·
1 Parent(s): 2515c3f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -7,38 +7,41 @@ import shutil
7
  import transformers.utils
8
  import gradio as gr
9
 
10
- # --- 1. SYSTEM MONITOR & PURGE ---
11
  def sovereign_init():
12
  process = psutil.Process(os.getpid())
13
  print(f"--- 🛡️ AIXYZone HARDWARE REPORT ---")
14
  print(f"Active Process ID: {os.getpid()}")
15
  print(f"Real Memory Usage: {process.memory_info().rss / 1024 / 1024:.2f} MB")
16
 
17
- # Clear old modules to force-load your new agents.py
18
  for module in ['agents', 'transformers', 'smolagents']:
19
  if module in sys.modules: del sys.modules[module]
20
 
21
- # Wipe cache to bypass any stuck "Payment Required" errors
22
  cache_dir = os.path.expanduser("~/.cache/huggingface")
23
  if os.path.exists(cache_dir): shutil.rmtree(cache_dir, ignore_errors=True)
24
 
25
  gc.collect()
26
- print("XYZ System: Total State Purge Complete.")
27
  print(f"----------------------------------", flush=True)
28
 
29
  sovereign_init()
30
 
31
- # --- 2. ENVIRONMENT HEALERS ---
 
32
  if not hasattr(transformers.utils, 'is_offline_mode'):
33
  transformers.utils.is_offline_mode = lambda: False
34
 
35
- # Patching the 'is_soundfile_availble' typo in smolagents
36
  if not hasattr(transformers.utils, 'is_soundfile_availble'):
37
  transformers.utils.is_soundfile_availble = lambda: False
 
38
 
 
39
  from agents import nano_patrol_agent
40
 
41
- # --- 3. SENTINEL LOGIC ---
42
  def run_autonomous_scrub(iterations):
43
  history = []
44
  bci_range = "3.4GHz - 4.2GHz (BCI/Neural Feedback)"
@@ -52,7 +55,7 @@ def run_autonomous_scrub(iterations):
52
  yield "\n\n".join(history[::-1])
53
  time.sleep(2)
54
 
55
- # --- 4. UI DESIGN ---
56
  with gr.Blocks(title="AIXYZone - BCI Nano Sentinel") as demo:
57
  gr.Markdown("# 🛡️ AIXYZone: Autonomous BCI Sentinel")
58
  with gr.Row():
 
7
  import transformers.utils
8
  import gradio as gr
9
 
10
+ # --- 1. TOTAL STATE PURGE & HARDWARE MONITOR ---
11
  def sovereign_init():
12
  process = psutil.Process(os.getpid())
13
  print(f"--- 🛡️ AIXYZone HARDWARE REPORT ---")
14
  print(f"Active Process ID: {os.getpid()}")
15
  print(f"Real Memory Usage: {process.memory_info().rss / 1024 / 1024:.2f} MB")
16
 
17
+ # Force Python to forget old, broken versions of your code
18
  for module in ['agents', 'transformers', 'smolagents']:
19
  if module in sys.modules: del sys.modules[module]
20
 
21
+ # Wipe local cache to clear "Payment Required" and corrupted data
22
  cache_dir = os.path.expanduser("~/.cache/huggingface")
23
  if os.path.exists(cache_dir): shutil.rmtree(cache_dir, ignore_errors=True)
24
 
25
  gc.collect()
26
+ print("XYZ System: Total State Purge Complete. Safe Zone Re-established.")
27
  print(f"----------------------------------", flush=True)
28
 
29
  sovereign_init()
30
 
31
+ # --- 2. ENVIRONMENT HEALERS (THE PATCHES) ---
32
+ # Patch 1: Fixes the 'is_offline_mode' crash
33
  if not hasattr(transformers.utils, 'is_offline_mode'):
34
  transformers.utils.is_offline_mode = lambda: False
35
 
36
+ # Patch 2: Fixes the 'is_soundfile_availble' typo in smolagents
37
  if not hasattr(transformers.utils, 'is_soundfile_availble'):
38
  transformers.utils.is_soundfile_availble = lambda: False
39
+ print("XYZ System: Library Typo Healed.")
40
 
41
+ # --- 3. LOAD AGENT ---
42
  from agents import nano_patrol_agent
43
 
44
+ # --- 4. SENTINEL LOGIC ---
45
  def run_autonomous_scrub(iterations):
46
  history = []
47
  bci_range = "3.4GHz - 4.2GHz (BCI/Neural Feedback)"
 
55
  yield "\n\n".join(history[::-1])
56
  time.sleep(2)
57
 
58
+ # --- 5. UI DESIGN ---
59
  with gr.Blocks(title="AIXYZone - BCI Nano Sentinel") as demo:
60
  gr.Markdown("# 🛡️ AIXYZone: Autonomous BCI Sentinel")
61
  with gr.Row():