Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def reflex_guard(scenario):
|
| 4 |
+
log = []
|
| 5 |
+
log.append("[ReflexGuard]: Scenario received – '{}'".format(scenario))
|
| 6 |
+
|
| 7 |
+
if "surge" in scenario.lower() or "override" in scenario.lower():
|
| 8 |
+
anomaly_score = 0.92
|
| 9 |
+
else:
|
| 10 |
+
anomaly_score = 0.21
|
| 11 |
+
|
| 12 |
+
log.append("[Analyzer]: Anomaly score = {:.2f}".format(anomaly_score))
|
| 13 |
+
if anomaly_score > 0.8:
|
| 14 |
+
log.append("[Decision]: HALT_SIGNAL issued due to risk threshold breach.")
|
| 15 |
+
else:
|
| 16 |
+
log.append("[Decision]: System stable. No action required.")
|
| 17 |
+
|
| 18 |
+
return { "logs": log }
|
| 19 |
+
|
| 20 |
+
demo = gr.Interface(fn=reflex_guard,
|
| 21 |
+
inputs=gr.Textbox(label="System Scenario"),
|
| 22 |
+
outputs="json",
|
| 23 |
+
live=False)
|
| 24 |
+
|
| 25 |
+
demo.launch()
|