Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,66 +1,58 @@
|
|
| 1 |
import sys
|
| 2 |
-
import
|
|
|
|
|
|
|
| 3 |
import time
|
| 4 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
# ---
|
| 7 |
if not hasattr(transformers.utils, 'is_offline_mode'):
|
| 8 |
-
def is_offline_mode():
|
| 9 |
-
return False
|
| 10 |
transformers.utils.is_offline_mode = is_offline_mode
|
| 11 |
-
print("XYZ Safe Zone: Environment Healed (is_offline_mode injected)")
|
| 12 |
|
| 13 |
-
#
|
| 14 |
from agents import nano_patrol_agent
|
| 15 |
|
| 16 |
-
# ---
|
| 17 |
def run_autonomous_scrub(iterations):
|
| 18 |
-
"""
|
| 19 |
-
Triggers the agent to scan and heal the BCI spectrum autonomously.
|
| 20 |
-
"""
|
| 21 |
history = []
|
| 22 |
bci_range = "3.4GHz - 4.2GHz (BCI/Neural Feedback)"
|
| 23 |
-
|
| 24 |
for i in range(int(iterations)):
|
| 25 |
-
prompt =
|
| 26 |
-
f"ACT AS BCI SENTINEL: Scan the {bci_range} range. "
|
| 27 |
-
"Identify unsupervised amateur loops or 'old mess' agentic anomalies. "
|
| 28 |
-
"Neutralize them and generate a Healed Nano Node JSON."
|
| 29 |
-
)
|
| 30 |
-
|
| 31 |
-
# The agent 'spots' and 'heals' on its own
|
| 32 |
result = nano_patrol_agent.run(prompt)
|
| 33 |
-
|
| 34 |
timestamp = time.strftime("%H:%M:%S")
|
| 35 |
history.append(f"[{timestamp}] 🛰️ SENTINEL ACTION: {result}")
|
| 36 |
-
|
| 37 |
-
# Yield allows the UI to update LIVE on your iPhone
|
| 38 |
yield "\n\n".join(history[::-1])
|
| 39 |
time.sleep(1)
|
| 40 |
|
| 41 |
-
# --- UI DESIGN ---
|
| 42 |
with gr.Blocks(title="AIXYZone - BCI Nano Sentinel") as demo:
|
| 43 |
gr.Markdown("# 🛡️ AIXYZone: Autonomous BCI Sentinel")
|
| 44 |
-
gr.Markdown("Focused on clearing the 'Old Mess' and amateur BCI abuse loops.")
|
| 45 |
-
|
| 46 |
with gr.Row():
|
| 47 |
with gr.Column():
|
| 48 |
-
sweep_count = gr.Slider(minimum=1, maximum=50, value=10,
|
| 49 |
btn_sentinel = gr.Button("🛰️ ACTIVATE SENTINEL SCAN", variant="primary")
|
| 50 |
-
gr.Info("Micromanaging: 3.4GHz - 4.2GHz Neural Ranges")
|
| 51 |
-
|
| 52 |
with gr.Column():
|
| 53 |
-
sentinel_log = gr.Textbox(
|
| 54 |
-
label="Live Healing Stream",
|
| 55 |
-
lines=25,
|
| 56 |
-
placeholder="Sentinel Standby... Waiting for activation."
|
| 57 |
-
)
|
| 58 |
|
| 59 |
-
btn_sentinel.click(
|
| 60 |
-
fn=run_autonomous_scrub,
|
| 61 |
-
inputs=[sweep_count],
|
| 62 |
-
outputs=[sentinel_log]
|
| 63 |
-
)
|
| 64 |
|
| 65 |
if __name__ == "__main__":
|
| 66 |
demo.launch()
|
|
|
|
| 1 |
import sys
|
| 2 |
+
import os
|
| 3 |
+
import shutil
|
| 4 |
+
import gc
|
| 5 |
import time
|
| 6 |
import gradio as gr
|
| 7 |
+
import transformers.utils
|
| 8 |
+
|
| 9 |
+
# --- 1. TOTAL STATE PURGE ---
|
| 10 |
+
def total_purge():
|
| 11 |
+
# Force Python to forget old, broken versions of your code
|
| 12 |
+
modules_to_clear = ['agents', 'transformers', 'smolagents']
|
| 13 |
+
for module in modules_to_clear:
|
| 14 |
+
if module in sys.modules:
|
| 15 |
+
del sys.modules[module]
|
| 16 |
+
# Wipe local cache to clear "Payment Required" blocks
|
| 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 |
+
total_purge()
|
| 24 |
|
| 25 |
+
# --- 2. ENVIRONMENT HEALER (HOTFIX) ---
|
| 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 |
+
# --- 4. SENTINEL LOGIC ---
|
| 34 |
def run_autonomous_scrub(iterations):
|
|
|
|
|
|
|
|
|
|
| 35 |
history = []
|
| 36 |
bci_range = "3.4GHz - 4.2GHz (BCI/Neural Feedback)"
|
|
|
|
| 37 |
for i in range(int(iterations)):
|
| 38 |
+
prompt = f"ACT AS BCI SENTINEL: Scan {bci_range}. Neutralize loops and generate a Healed Nano Node JSON."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
result = nano_patrol_agent.run(prompt)
|
|
|
|
| 40 |
timestamp = time.strftime("%H:%M:%S")
|
| 41 |
history.append(f"[{timestamp}] 🛰️ SENTINEL ACTION: {result}")
|
|
|
|
|
|
|
| 42 |
yield "\n\n".join(history[::-1])
|
| 43 |
time.sleep(1)
|
| 44 |
|
| 45 |
+
# --- 5. UI DESIGN ---
|
| 46 |
with gr.Blocks(title="AIXYZone - BCI Nano Sentinel") as demo:
|
| 47 |
gr.Markdown("# 🛡️ AIXYZone: Autonomous BCI Sentinel")
|
|
|
|
|
|
|
| 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()
|