PoetNameLife commited on
Commit
0aff28e
·
verified ·
1 Parent(s): 746e0c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -65
app.py CHANGED
@@ -7,84 +7,48 @@ 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
- # Force-clear Python's cache to load your new agents.py
18
  for module in ['agents', 'transformers', 'smolagents']:
19
  if module in sys.modules: del sys.modules[module]
20
-
21
- # Purge local cache to bypass stuck "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
- # Fixes the 'is_soundfile_availble' typo in the smolagents library
36
- if not hasattr(transformers.utils, 'is_soundfile_availble'):
37
- transformers.utils.is_soundfile_availble = lambda: False
38
- print("XYZ System: Library Typo Healed.")
39
 
40
  from agents import nano_patrol_agent
41
 
42
- # --- 3. BLACK EAGLE & SENTINEL LOGIC ---
43
  def run_autonomous_scrub(iterations):
44
  history = []
45
- bci_range = "3.4GHz - 4.2GHz (Neural Feedback)"
46
-
47
  for i in range(int(iterations)):
48
- # MANDATE: Command the sentinel to engage BOTH the shield and the scan
49
- prompt = (
50
- f"ACT AS BCI SENTINEL: 1. Launch the Pulsating Black Eagle shield with a 5m radius. "
51
- f"2. Simultaneously scan {bci_range} to neutralize loops. "
52
- "3. Generate a combined Healed Nano Node JSON report."
53
- )
54
-
55
- try:
56
- result = nano_patrol_agent.run(prompt)
57
- timestamp = time.strftime("%H:%M:%S")
58
- history.append(f"[{timestamp}] 🛰️ BLACK EAGLE OPS: {result}")
59
- except Exception as e:
60
- history.append(f"SHIELD ERROR: {str(e)}")
61
-
62
- yield "\n\n".join(history[::-1])
63
- time.sleep(3) # Buffer for dual-tool processing
64
-
65
- # --- 4. UI DESIGN ---
66
- with gr.Blocks(title="AIXYZone - BCI Nano Sentinel") as demo:
67
- gr.Markdown("# 🛡️ AIXYZone: Autonomous BCI Sentinel")
68
- gr.Markdown("Focused on clearing the 'Old Mess' and amateur BCI abuse loops.")
69
-
70
  with gr.Row():
71
- with gr.Column():
72
- sweep_count = gr.Slider(minimum=1, maximum=50, value=10, step=1, label="Autonomous Scrub Depth")
73
- btn_sentinel = gr.Button("🛰️ ACTIVATE SENTINEL SCAN", variant="primary")
74
- gr.Info("Micromanaging: 3.4GHz - 4.2GHz Neural Ranges")
75
-
76
- with gr.Column():
77
- sentinel_log = gr.Textbox(
78
- label="Live Healing Stream",
79
- lines=25,
80
- placeholder="Sentinel Standby... Waiting for activation."
81
- )
82
 
83
- btn_sentinel.click(
84
- fn=run_autonomous_scrub,
85
- inputs=[sweep_count],
86
- outputs=[sentinel_log]
87
- )
88
 
89
- if __name__ == "__main__":
90
- demo.launch()
 
7
  import transformers.utils
8
  import gradio as gr
9
 
10
+ # --- 1. SYSTEM INIT & PURGE ---
11
  def sovereign_init():
 
 
 
 
 
 
12
  for module in ['agents', 'transformers', 'smolagents']:
13
  if module in sys.modules: del sys.modules[module]
 
 
 
 
 
14
  gc.collect()
 
 
15
 
16
  sovereign_init()
17
 
18
+ if not hasattr(transformers.utils, 'is_offline_mode'): transformers.utils.is_offline_mode = lambda: False
19
+ if not hasattr(transformers.utils, 'is_soundfile_availble'): transformers.utils.is_soundfile_availble = lambda: False
 
 
 
 
 
 
20
 
21
  from agents import nano_patrol_agent
22
 
23
+ # --- 2. SENTINEL & VAULT LOGIC ---
24
  def run_autonomous_scrub(iterations):
25
  history = []
 
 
26
  for i in range(int(iterations)):
27
+ prompt = "ACT AS SENTINEL: Engage Pulsating Shield, Scan BCI 3.8GHz, and SAVE result to Vault."
28
+ result = nano_patrol_agent.run(prompt)
29
+ history.append(f"[{time.strftime('%H:%M:%S')}] 🛰️ OPS: {result}")
30
+ yield "\n\n".join(history[::-1])
31
+ time.sleep(2)
32
+
33
+ def view_vault():
34
+ if os.path.exists("black_eagle_vault.json"):
35
+ with open("black_eagle_vault.json", "r") as f: return f.read()
36
+ return "Vault is empty."
37
+
38
+ # --- 3. UI ---
39
+ with gr.Blocks() as demo:
40
+ gr.Markdown("# 🛡️ AIXYZone: Black Eagle Sentinel")
 
 
 
 
 
 
 
 
41
  with gr.Row():
42
+ sweep = gr.Slider(1, 50, value=10, label="Scrub Depth")
43
+ btn = gr.Button("🛰️ ACTIVATE SCAN", variant="primary")
44
+
45
+ log = gr.Textbox(label="Live Stream", lines=15)
46
+
47
+ with gr.Accordion("📂 BLACK BOX STORAGE", open=False):
48
+ btn_vault = gr.Button("VIEW ARCHIVED NODES")
49
+ vault_out = gr.Code(label="Vault Data", language="json")
 
 
 
50
 
51
+ btn.click(run_autonomous_scrub, inputs=[sweep], outputs=[log])
52
+ btn_vault.click(fn=view_vault, outputs=[vault_out])
 
 
 
53
 
54
+ demo.launch()