petter2025 commited on
Commit
66ca8ba
·
verified ·
1 Parent(s): 4bb8728

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -22,6 +22,9 @@ from plotly.subplots import make_subplots
22
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
23
  logger = logging.getLogger(__name__)
24
 
 
 
 
25
  # ARF components
26
  from agentic_reliability_framework.runtime.engine import EnhancedReliabilityEngine
27
  from agentic_reliability_framework.core.models.event import ReliabilityEvent
@@ -484,6 +487,26 @@ def generate_action_timeline():
484
  fig.update_layout(title="Autonomous Actions Timeline", xaxis_title="Time", yaxis_title="Approved (1) / Blocked (0)")
485
  return fig
486
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
487
  # ----------------------------------------------------------------------
488
  # Gradio UI with Governance Focus
489
  # ----------------------------------------------------------------------
@@ -532,8 +555,8 @@ with gr.Blocks(title="ARF v4 – Autonomous AI Control Plane", theme="soft") as
532
  # Refresh button for dashboard
533
  refresh_dash_btn = gr.Button("Refresh Dashboard")
534
  refresh_dash_btn.click(
535
- fn=lambda: (generate_risk_gauge(), generate_decision_pie(), generate_action_timeline()),
536
- outputs=[risk_gauge, decision_pie, action_timeline]
537
  )
538
 
539
  # Tab 2: Text Generation with Governance
 
22
  logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
23
  logger = logging.getLogger(__name__)
24
 
25
+ # Global variable for feedback
26
+ last_task_category = None
27
+
28
  # ARF components
29
  from agentic_reliability_framework.runtime.engine import EnhancedReliabilityEngine
30
  from agentic_reliability_framework.core.models.event import ReliabilityEvent
 
487
  fig.update_layout(title="Autonomous Actions Timeline", xaxis_title="Time", yaxis_title="Approved (1) / Blocked (0)")
488
  return fig
489
 
490
+ # ========== Dashboard Refresh Function ==========
491
+ def refresh_dashboard():
492
+ """Compute latest stats and return updated dashboard components."""
493
+ total = len(decision_history)
494
+ approved = sum(1 for _, d, _ in decision_history if d.get("approved", False))
495
+ blocked = total - approved
496
+ avg_risk = np.mean([r for _, r in risk_history]) if risk_history else 0.5
497
+ control_stats = {
498
+ "total_decisions": total,
499
+ "approved_actions": approved,
500
+ "blocked_actions": blocked,
501
+ "average_risk": float(avg_risk)
502
+ }
503
+ return (
504
+ control_stats,
505
+ generate_risk_gauge(),
506
+ generate_decision_pie(),
507
+ generate_action_timeline()
508
+ )
509
+
510
  # ----------------------------------------------------------------------
511
  # Gradio UI with Governance Focus
512
  # ----------------------------------------------------------------------
 
555
  # Refresh button for dashboard
556
  refresh_dash_btn = gr.Button("Refresh Dashboard")
557
  refresh_dash_btn.click(
558
+ fn=refresh_dashboard,
559
+ outputs=[control_stats, risk_gauge, decision_pie, action_timeline]
560
  )
561
 
562
  # Tab 2: Text Generation with Governance