Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,84 +7,48 @@ import shutil
|
|
| 7 |
import transformers.utils
|
| 8 |
import gradio as gr
|
| 9 |
|
| 10 |
-
# --- 1. SYSTEM
|
| 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 |
-
|
| 32 |
-
if not hasattr(transformers.utils, '
|
| 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 |
-
# ---
|
| 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 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 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 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
lines=25,
|
| 80 |
-
placeholder="Sentinel Standby... Waiting for activation."
|
| 81 |
-
)
|
| 82 |
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
inputs=[sweep_count],
|
| 86 |
-
outputs=[sentinel_log]
|
| 87 |
-
)
|
| 88 |
|
| 89 |
-
|
| 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()
|
|
|