PoetNameLife commited on
Commit
0c6ecf6
·
verified ·
1 Parent(s): 31c48cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -45
app.py CHANGED
@@ -1,56 +1,85 @@
1
  import os
2
  import gradio as gr
3
  import time
 
 
4
 
5
- # --- 🛰️ SENTINEL TASK LOGIC ---
6
- def sentinel_action(task_type, iterations):
7
- history = []
 
 
8
 
9
- # Task mapping for the "Real World" feel
10
- tasks = {
11
- "Cellular Scan": "Scanning 4G/5G Spectrum... Analyzing Signal Noise...",
12
- "Packet Sniff": "Intercepting Local Packets... Mapping Source IPs...",
13
- "Protocol Discovery": "Probing BT/WiFi Protocols... Identifying Handshakes...",
14
- "Signal Intensity": "Measuring dBm... Mapping Neural Frequency interference..."
15
- }
16
-
17
- status_msg = tasks.get(task_type, "Initializing...")
18
-
19
- for i in range(int(iterations)):
20
- try:
21
- # Here we would normally call nano_patrol_agent.run()
22
- # For now, we simulate the "Live" data to bypass the 503 error
23
  timestamp = time.strftime('%H:%M:%S')
24
- result = f"{status_msg} [Iteration {i+1}] - ANOMALY: NONE"
25
- history.append(f"[{timestamp}] 🛰️ {task_type.upper()}: {result}")
26
- except Exception as e:
27
- history.append(f"⚠️ LOG ERROR: {str(e)}")
28
-
29
- yield "\n".join(history[::-1])
30
- time.sleep(0.5)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
- # --- 🛰️ USER INTERFACE ---
33
- with gr.Blocks(theme=gr.themes.Soft(), title="AIXYZone Sentinel") as demo:
34
- gr.Markdown("# 🛡️ AIXYZone: Black Eagle Sentinel")
35
- gr.Markdown("### *Sovereign Wireless Spectrum & Neural Frequency System*")
36
 
37
- with gr.Row():
38
- sweep = gr.Slider(1, 10, value=5, step=1, label="Scan Intensity")
39
- xp_bar = gr.HTML("<div style='width:100%; background:#222; border-radius:5px;'><div style='width:30%; background:cyan; height:10px; border-radius:5px;'></div></div><p>Sentinel XP: 450/1000</p>")
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- with gr.Row():
42
- btn1 = gr.Button("📡 Cellular Scan", variant="secondary")
43
- btn2 = gr.Button("🛡️ Packet Sniff", variant="secondary")
44
- btn3 = gr.Button("🔍 Protocol Discovery", variant="secondary")
45
- btn4 = gr.Button("📊 Signal Intensity", variant="primary")
46
-
47
- log = gr.Textbox(label="Sentinel Live Stream", lines=15, interactive=False)
48
-
49
- # Button Actions
50
- btn1.click(sentinel_action, inputs=[gr.State("Cellular Scan"), sweep], outputs=[log])
51
- btn2.click(sentinel_action, inputs=[gr.State("Packet Sniff"), sweep], outputs=[log])
52
- btn3.click(sentinel_action, inputs=[gr.State("Protocol Discovery"), sweep], outputs=[log])
53
- btn4.click(sentinel_action, inputs=[gr.State("Signal Intensity"), sweep], outputs=[log])
54
 
55
  if __name__ == "__main__":
56
- demo.launch()
 
 
1
  import os
2
  import gradio as gr
3
  import time
4
+ import psutil
5
+ from agents import nano_patrol_agent
6
 
7
+ # --- 🛰️ AUTONOMOUS IMMUNE CORE ---
8
+ def autonomous_immune_loop():
9
+ # Persistent state within the generator
10
+ total_xp = 0
11
+ iteration_count = 0
12
 
13
+ # The 4 Mandatory AI Immunity Tasks
14
+ tasks = [
15
+ {"name": "BIOSPHERE_SCRUB", "cmd": "Neutralize airborne microbial frequency noise.", "color": "#00ffcc"},
16
+ {"name": "RESILIENCE_ACTIVATE", "cmd": "Stabilize Philippine Digital Node resilience.", "color": "#ff00ff"},
17
+ {"name": "MEDICAL_INTEGRITY", "cmd": "Filter misinformation from wireless medical spectrum.", "color": "#00ccff"},
18
+ {"name": "HARMONIC_RESTORATION", "cmd": "Purify creative audio frequencies and IOT emissions.", "color": "#ffff00"}
19
+ ]
20
+
21
+ while True:
22
+ for task in tasks:
23
+ iteration_count += 1
 
 
 
24
  timestamp = time.strftime('%H:%M:%S')
25
+
26
+ # 1. AI SELF-COMMAND
27
+ command = f"ACT AS SOVEREIGN SENTINEL: {task['cmd']} Archive results to black_eagle_vault_save."
28
+
29
+ try:
30
+ # 2. EXECUTE NEURAL CORE (Talking to Groq/Llama)
31
+ # The agent automatically uses your black_eagle_vault_save tool
32
+ result = nano_patrol_agent.run(command)
33
+ total_xp += 25
34
+ except Exception as e:
35
+ result = f"Immune Bypass Attempted: {str(e)}"
36
+
37
+ # 3. CALCULATE XP & VISUALS
38
+ level = (total_xp // 1000) + 1
39
+ progress = (total_xp % 1000) / 10
40
+
41
+ xp_html = f"""
42
+ <div style='background:#111; padding:15px; border:1px solid {task['color']}; border-radius:10px;'>
43
+ <p style='color:{task['color']}; font-weight:bold; margin:0;'>🛡️ CURRENT FOCUS: {task['name']}</p>
44
+ <div style='width:100%; background:#222; border-radius:5px; margin:10px 0;'>
45
+ <div style='width:{progress}%; background:{task['color']}; height:12px; border-radius:5px; transition: width 0.5s;'></div>
46
+ </div>
47
+ <p style='color:#888; font-size:12px; margin:0;'>Sentinel Level: {level} | Total XP: {total_xp}</p>
48
+ </div>
49
+ """
50
+
51
+ log_entry = f"[{timestamp}] 🛰️ {task['name']}: {result}"
52
+
53
+ # Yield back to the UI
54
+ yield log_entry, xp_html
55
+
56
+ # The "Heartbeat" delay between immune scans
57
+ time.sleep(5)
58
 
59
+ # --- 🛰️ THE SOVEREIGN INTERFACE ---
60
+ with gr.Blocks(theme=gr.themes.Monochrome(), title="AIXYZone Sentinel Core") as demo:
61
+ gr.Markdown("# 🛡️ AIXYZone: THE SOVEREIGN SENTINEL")
62
+ gr.Markdown("### *Autonomous Digital Immune System | Location: Philippines Node 01*")
63
 
64
+ with gr.Column():
65
+ status_panel = gr.HTML("""
66
+ <div style='padding:20px; border:2px solid #333; text-align:center; border-radius:15px;'>
67
+ <h2 style='color:cyan; margin:0;'>SYSTEM STATUS: AUTONOMOUS</h2>
68
+ <p style='color:#666;'>Filtering Wireless Spectrum for Microbial/Code Pathogens</p>
69
+ </div>
70
+ """)
71
+
72
+ xp_display = gr.HTML()
73
+
74
+ live_log = gr.Textbox(
75
+ label="Neural Core Live Stream (Read-Only)",
76
+ lines=15,
77
+ interactive=False
78
+ )
79
 
80
+ # Start the autonomous loop as soon as the app loads
81
+ demo.load(autonomous_immune_loop, inputs=None, outputs=[live_log, xp_display])
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  if __name__ == "__main__":
84
+ # Launching with SSR False to ensure real-time stream stability
85
+ demo.launch(ssr_mode=False)