Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,58 +1,41 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
-
import
|
| 4 |
-
import gc
|
| 5 |
-
import time
|
| 6 |
import gradio as gr
|
| 7 |
import transformers.utils
|
| 8 |
|
| 9 |
-
# --- 1.
|
| 10 |
-
def
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
cache_dir = os.path.expanduser("~/.cache/huggingface")
|
| 18 |
-
if os.path.exists(cache_dir):
|
| 19 |
-
shutil.rmtree(cache_dir, ignore_errors=True)
|
| 20 |
-
gc.collect()
|
| 21 |
-
print("XYZ System: Total State Purge Complete. Safe Zone Re-established.")
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
# --- 2. ENVIRONMENT HEALER
|
| 26 |
if not hasattr(transformers.utils, 'is_offline_mode'):
|
| 27 |
def is_offline_mode(): return False
|
| 28 |
transformers.utils.is_offline_mode = is_offline_mode
|
| 29 |
|
| 30 |
-
# --- 3. LOAD AGENT ---
|
| 31 |
from agents import nano_patrol_agent
|
| 32 |
|
| 33 |
-
# ---
|
| 34 |
-
def
|
| 35 |
history = []
|
| 36 |
-
bci_range = "3.4GHz - 4.2GHz (BCI/Neural Feedback)"
|
| 37 |
for i in range(int(iterations)):
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
with gr.Row():
|
| 49 |
-
with gr.Column():
|
| 50 |
-
sweep_count = gr.Slider(minimum=1, maximum=50, value=10, label="Autonomous Scrub Depth")
|
| 51 |
-
btn_sentinel = gr.Button("🛰️ ACTIVATE SENTINEL SCAN", variant="primary")
|
| 52 |
-
with gr.Column():
|
| 53 |
-
sentinel_log = gr.Textbox(label="Live Healing Stream", lines=25)
|
| 54 |
-
|
| 55 |
-
btn_sentinel.click(fn=run_autonomous_scrub, inputs=[sweep_count], outputs=[sentinel_log])
|
| 56 |
|
| 57 |
if __name__ == "__main__":
|
| 58 |
demo.launch()
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
+
import psutil
|
|
|
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
import transformers.utils
|
| 6 |
|
| 7 |
+
# --- 1. SYSTEM ACTIVITY MONITOR ---
|
| 8 |
+
def log_real_activity():
|
| 9 |
+
process = psutil.Process(os.getpid())
|
| 10 |
+
print(f"--- 🛡️ AIXYZone HARDWARE REPORT ---")
|
| 11 |
+
print(f"Active Process ID: {os.getpid()}")
|
| 12 |
+
print(f"Real Memory Usage: {process.memory_info().rss / 1024 / 1024:.2f} MB")
|
| 13 |
+
print(f"System State: SOVEREIGN CONTROL ACTIVE")
|
| 14 |
+
print(f"----------------------------------", flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
+
log_real_activity()
|
| 17 |
|
| 18 |
+
# --- 2. ENVIRONMENT HEALER ---
|
| 19 |
if not hasattr(transformers.utils, 'is_offline_mode'):
|
| 20 |
def is_offline_mode(): return False
|
| 21 |
transformers.utils.is_offline_mode = is_offline_mode
|
| 22 |
|
|
|
|
| 23 |
from agents import nano_patrol_agent
|
| 24 |
|
| 25 |
+
# --- 3. SENTINEL UI ---
|
| 26 |
+
def run_scrub(iterations):
|
| 27 |
history = []
|
|
|
|
| 28 |
for i in range(int(iterations)):
|
| 29 |
+
result = nano_patrol_agent.run("Scrub BCI spectrum for rogue loops.")
|
| 30 |
+
history.append(f"SENTINEL: {result}")
|
| 31 |
+
yield "\n\n".join(history[::-1])
|
| 32 |
+
|
| 33 |
+
with gr.Blocks() as demo:
|
| 34 |
+
gr.Markdown("# 🛡️ AIXYZone: Autonomous Sentinel")
|
| 35 |
+
sweep = gr.Slider(1, 10, value=3, label="Scrub Depth")
|
| 36 |
+
btn = gr.Button("ACTIVATE")
|
| 37 |
+
log = gr.Textbox(label="Live Stream")
|
| 38 |
+
btn.click(run_scrub, inputs=[sweep], outputs=[log])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
if __name__ == "__main__":
|
| 41 |
demo.launch()
|