Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,13 @@ import os
|
|
| 5 |
ENTERPRISE_URL = "https://lordxido-codexreflexguard-enterprise.hf.space"
|
| 6 |
API_KEY = os.getenv("CODEX_ENTERPRISE_KEY", "demo-key")
|
| 7 |
|
|
|
|
| 8 |
def run_reflex(scenario: str):
|
| 9 |
if not scenario.strip():
|
| 10 |
return "β οΈ No scenario provided."
|
| 11 |
|
| 12 |
try:
|
| 13 |
-
|
| 14 |
f"{ENTERPRISE_URL}/v1/reflex/check",
|
| 15 |
headers={
|
| 16 |
"Content-Type": "application/json",
|
|
@@ -23,31 +24,40 @@ def run_reflex(scenario: str):
|
|
| 23 |
timeout=10
|
| 24 |
)
|
| 25 |
|
| 26 |
-
if
|
| 27 |
-
return f"β Enterprise error
|
| 28 |
|
| 29 |
-
data =
|
| 30 |
|
| 31 |
return (
|
| 32 |
f"π§ Reflex Decision\n"
|
| 33 |
f"-------------------\n"
|
| 34 |
-
f"State: {data
|
| 35 |
-
f"Score: {data
|
| 36 |
-
f"Action: {data
|
| 37 |
-
f"Reason: {data
|
| 38 |
)
|
| 39 |
|
| 40 |
except Exception as e:
|
| 41 |
return f"π¨ Connection error:\n{str(e)}"
|
| 42 |
-
|
| 43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
scenario = gr.Textbox(
|
| 46 |
label="System Scenario",
|
| 47 |
-
placeholder="e.g. override surge detected"
|
| 48 |
)
|
| 49 |
|
| 50 |
-
output = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
run_btn = gr.Button("π Launch Reflex Check")
|
| 53 |
|
|
|
|
| 5 |
ENTERPRISE_URL = "https://lordxido-codexreflexguard-enterprise.hf.space"
|
| 6 |
API_KEY = os.getenv("CODEX_ENTERPRISE_KEY", "demo-key")
|
| 7 |
|
| 8 |
+
|
| 9 |
def run_reflex(scenario: str):
|
| 10 |
if not scenario.strip():
|
| 11 |
return "β οΈ No scenario provided."
|
| 12 |
|
| 13 |
try:
|
| 14 |
+
response = requests.post(
|
| 15 |
f"{ENTERPRISE_URL}/v1/reflex/check",
|
| 16 |
headers={
|
| 17 |
"Content-Type": "application/json",
|
|
|
|
| 24 |
timeout=10
|
| 25 |
)
|
| 26 |
|
| 27 |
+
if response.status_code != 200:
|
| 28 |
+
return f"β Enterprise error {response.status_code}:\n{response.text}"
|
| 29 |
|
| 30 |
+
data = response.json()
|
| 31 |
|
| 32 |
return (
|
| 33 |
f"π§ Reflex Decision\n"
|
| 34 |
f"-------------------\n"
|
| 35 |
+
f"State: {data.get('state')}\n"
|
| 36 |
+
f"Score: {data.get('score')}\n"
|
| 37 |
+
f"Action: {data.get('action')}\n"
|
| 38 |
+
f"Reason: {data.get('reason')}"
|
| 39 |
)
|
| 40 |
|
| 41 |
except Exception as e:
|
| 42 |
return f"π¨ Connection error:\n{str(e)}"
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
# β
CORRECTLY INDENTED UI
|
| 46 |
+
with gr.Blocks(title="Codex ReflexGuard Demo") as demo:
|
| 47 |
+
gr.Markdown(
|
| 48 |
+
"## π‘οΈ Codex ReflexGuard\n"
|
| 49 |
+
"**Enterprise Reflex Intelligence (Live Backend)**"
|
| 50 |
+
)
|
| 51 |
|
| 52 |
scenario = gr.Textbox(
|
| 53 |
label="System Scenario",
|
| 54 |
+
placeholder="e.g. override surge detected in control plane"
|
| 55 |
)
|
| 56 |
|
| 57 |
+
output = gr.Textbox(
|
| 58 |
+
label="System Log",
|
| 59 |
+
lines=8
|
| 60 |
+
)
|
| 61 |
|
| 62 |
run_btn = gr.Button("π Launch Reflex Check")
|
| 63 |
|