LordXido commited on
Commit
e7eb406
Β·
verified Β·
1 Parent(s): 4653c9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -12
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
- r = requests.post(
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 r.status_code != 200:
27
- return f"❌ Enterprise error: {r.status_code}\n{r.text}"
28
 
29
- data = r.json()
30
 
31
  return (
32
  f"🧠 Reflex Decision\n"
33
  f"-------------------\n"
34
- f"State: {data['state']}\n"
35
- f"Score: {data['score']}\n"
36
- f"Action: {data['action']}\n"
37
- f"Reason: {data['reason']}"
38
  )
39
 
40
  except Exception as e:
41
  return f"🚨 Connection error:\n{str(e)}"
42
- with gr.Blocks(title="Codex ReflexGuard Demo") as demo:
43
- gr.Markdown("## πŸ›‘οΈ Codex ReflexGuard\nEnterprise Reflex Intelligence")
 
 
 
 
 
 
44
 
45
  scenario = gr.Textbox(
46
  label="System Scenario",
47
- placeholder="e.g. override surge detected"
48
  )
49
 
50
- output = gr.Textbox(label="System Log", lines=8)
 
 
 
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