Spaces:
Paused
Paused
File size: 2,681 Bytes
ea2a7d9 4110190 b449d6b 4110190 ea2a7d9 4110190 ea2a7d9 54dba90 4110190 b449d6b 4110190 54dba90 895834b 4110190 54dba90 4110190 895834b 4110190 54dba90 b449d6b ea2a7d9 4110190 d679539 54dba90 d679539 4110190 d679539 54dba90 4110190 cc71b6e 4110190 39c0efc 54dba90 4110190 19d8abb 4110190 19d8abb 4110190 54dba90 4110190 895834b 4110190 895834b 4110190 54dba90 4110190 895834b 4110190 895834b 39c0efc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import os
import sys
import gc
import time
import psutil
import shutil
import transformers.utils
import gradio as gr
# --- 1. SOVEREIGN PURGE & MONITOR ---
def sovereign_init():
process = psutil.Process(os.getpid())
print(f"--- 🛡️ AIXYZone HARDWARE REPORT ---")
print(f"Active Process ID: {os.getpid()}")
print(f"Real Memory Usage: {process.memory_info().rss / 1024 / 1024:.2f} MB")
# Force-clear Python's cache to load your new agents.py
for module in ['agents', 'transformers', 'smolagents']:
if module in sys.modules: del sys.modules[module]
# Purge local cache to bypass stuck "Payment Required" states
cache_dir = os.path.expanduser("~/.cache/huggingface")
if os.path.exists(cache_dir): shutil.rmtree(cache_dir, ignore_errors=True)
gc.collect()
print("XYZ System: Total State Purge Complete.")
print(f"----------------------------------", flush=True)
sovereign_init()
# --- 2. ENVIRONMENT HEALERS ---
if not hasattr(transformers.utils, 'is_offline_mode'):
transformers.utils.is_offline_mode = lambda: False
# Fixes the 'is_soundfile_availble' typo in the smolagents library
if not hasattr(transformers.utils, 'is_soundfile_availble'):
transformers.utils.is_soundfile_availble = lambda: False
print("XYZ System: Library Typo Healed.")
from agents import nano_patrol_agent
# --- 3. SENTINEL LOGIC ---
def run_autonomous_scrub(iterations):
history = []
bci_range = "3.4GHz - 4.2GHz (BCI/Neural Feedback)"
for i in range(int(iterations)):
prompt = f"ACT AS BCI SENTINEL: Scan {bci_range}. Neutralize loops and generate a Healed Nano Node JSON."
try:
# The agent uses your new HF_TOKEN/HF_HUB_TOKEN automatically
result = nano_patrol_agent.run(prompt)
history.append(f"[{time.strftime('%H:%M:%S')}] 🛰️ SENTINEL ACTION: {result}")
except Exception as e:
history.append(f"LOG ERROR: {str(e)}")
yield "\n\n".join(history[::-1])
time.sleep(2)
# --- 4. UI DESIGN ---
with gr.Blocks(title="AIXYZone - BCI Nano Sentinel") as demo:
gr.Markdown("# 🛡️ AIXYZone: Autonomous BCI Sentinel")
with gr.Row():
with gr.Column():
sweep_count = gr.Slider(minimum=1, maximum=50, value=10, label="Autonomous Scrub Depth")
btn_sentinel = gr.Button("🛰️ ACTIVATE SENTINEL SCAN", variant="primary")
with gr.Column():
sentinel_log = gr.Textbox(label="Live Healing Stream", lines=25)
btn_sentinel.click(fn=run_autonomous_scrub, inputs=[sweep_count], outputs=[sentinel_log])
if __name__ == "__main__":
demo.launch()
|