PoetNameLife commited on
Commit
bd08251
·
verified ·
1 Parent(s): 75bb9ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -30
app.py CHANGED
@@ -7,59 +7,66 @@ import shutil
7
  import transformers.utils
8
  import gradio as gr
9
 
10
- # --- 1. SYSTEM PURGE ---
11
  def sovereign_init():
12
- print("--- 🛡️ AIXYZone HARDWARE REPORT ---")
 
 
 
 
 
13
  for module in ['agents', 'transformers', 'smolagents']:
14
  if module in sys.modules: del sys.modules[module]
 
 
 
 
 
15
  gc.collect()
16
  print("XYZ System: Total State Purge Complete.")
 
17
 
18
  sovereign_init()
19
 
20
- # Fix common library typos and offline modes
21
- if not hasattr(transformers.utils, 'is_offline_mode'): transformers.utils.is_offline_mode = lambda: False
22
- if not hasattr(transformers.utils, 'is_soundfile_availble'): transformers.utils.is_soundfile_availble = lambda: False
 
 
 
23
 
24
  from agents import nano_patrol_agent
25
 
26
- # --- 2. SENTINEL & VAULT LOGIC ---
27
  def run_autonomous_scrub(iterations):
28
  history = []
 
29
  for i in range(int(iterations)):
30
- prompt = "ACT AS SENTINEL: Engage Pulsating Shield, Scan BCI 3.8GHz, and SAVE result to Vault."
 
 
 
 
 
31
  try:
32
  result = nano_patrol_agent.run(prompt)
33
  history.append(f"[{time.strftime('%H:%M:%S')}] 🛰️ OPS: {result}")
34
  except Exception as e:
35
  history.append(f"LOG ERROR: {str(e)}")
36
- yield "\n\n".join(history[::-1])
37
  time.sleep(2)
38
 
39
- def view_vault():
40
- vault_path = "black_eagle_vault.json"
41
- # Hardware-level file check
42
- if os.path.exists(vault_path) and os.stat(vault_path).st_size > 2:
43
- with open(vault_path, "r") as f:
44
- return f.read()
45
- return "Vault is currently empty. Run an active scan first to populate the Black Box!"
46
-
47
- # --- 3. UI DESIGN ---
48
- with gr.Blocks(title="AIXYZone Black Eagle") as demo:
49
- gr.Markdown("# 🛡️ AIXYZone: Black Eagle Sentinel Dashboard")
50
  with gr.Row():
51
- sweep = gr.Slider(1, 50, value=10, label="Scrub Depth (Iterations)")
52
- btn = gr.Button("🛰️ ACTIVATE SENTINEL SCAN", variant="primary")
53
-
54
- log = gr.Textbox(label="Live Healing Stream", lines=15)
55
-
56
- with gr.Accordion("📂 BLACK BOX STORAGE (Vault)", open=False):
57
- gr.Markdown("Permanent archive of all healed BCI nodes.")
58
- btn_vault = gr.Button("🔄 REFRESH & VIEW VAULT")
59
- vault_out = gr.Code(label="Vault Data (JSON)", language="json")
60
 
61
- btn.click(run_autonomous_scrub, inputs=[sweep], outputs=[log])
62
- btn_vault.click(fn=view_vault, outputs=[vault_out])
63
 
64
  if __name__ == "__main__":
65
  demo.launch()
 
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 local cache to clear old "Payment Required" states
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
+ if not hasattr(transformers.utils, 'is_soundfile_availble'):
36
+ transformers.utils.is_soundfile_availble = lambda: False
37
 
38
  from agents import nano_patrol_agent
39
 
40
+ # --- 3. SENTINEL & HUB-VAULT LOGIC ---
41
  def run_autonomous_scrub(iterations):
42
  history = []
43
+ bci_range = "3.4GHz - 4.2GHz (BCI/Neural Feedback)"
44
  for i in range(int(iterations)):
45
+ # MANDATE: Engage the shield, scan the spectrum, and PUSH to Hub
46
+ prompt = (
47
+ f"ACT AS BCI SENTINEL: 1. Launch the Pulsating Black Eagle shield. "
48
+ f"2. Scan {bci_range} to neutralize loops. "
49
+ f"3. Use 'black_eagle_vault_save' to push the HEALED INNOVATION REPORT to the Hub Vault."
50
+ )
51
  try:
52
  result = nano_patrol_agent.run(prompt)
53
  history.append(f"[{time.strftime('%H:%M:%S')}] 🛰️ OPS: {result}")
54
  except Exception as e:
55
  history.append(f"LOG ERROR: {str(e)}")
56
+ yield "\n\n".join(history[::-1])
57
  time.sleep(2)
58
 
59
+ # --- 4. UI DESIGN ---
60
+ with gr.Blocks(title="AIXYZone - BCI Nano Sentinel") as demo:
61
+ gr.Markdown("# 🛡️ AIXYZone: Autonomous BCI Sentinel")
 
 
 
 
 
 
 
 
62
  with gr.Row():
63
+ with gr.Column():
64
+ sweep_count = gr.Slider(minimum=1, maximum=50, value=10, label="Autonomous Scrub Depth")
65
+ btn_sentinel = gr.Button("🛰️ ACTIVATE SENTINEL SCAN", variant="primary")
66
+ with gr.Column():
67
+ sentinel_log = gr.Textbox(label="Live Healing Stream", lines=25)
 
 
 
 
68
 
69
+ btn_sentinel.click(fn=run_autonomous_scrub, inputs=[sweep_count], outputs=[sentinel_log])
 
70
 
71
  if __name__ == "__main__":
72
  demo.launch()