File size: 1,746 Bytes
517f16d
4676865
517f16d
 
 
 
 
e7eb406
517f16d
 
 
 
 
e7eb406
517f16d
 
 
 
 
 
 
 
 
 
 
 
e7eb406
 
517f16d
e7eb406
517f16d
 
 
 
e7eb406
 
 
 
517f16d
 
 
4653c9a
e7eb406
 
 
 
 
 
 
 
4653c9a
 
 
e7eb406
4653c9a
 
e7eb406
 
 
 
4653c9a
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import requests
import gradio as gr
import os

ENTERPRISE_URL = "https://lordxido-codexreflexguard-enterprise.hf.space"
API_KEY = os.getenv("CODEX_ENTERPRISE_KEY", "demo-key")


def run_reflex(scenario: str):
    if not scenario.strip():
        return "โš ๏ธ No scenario provided."

    try:
        response = requests.post(
            f"{ENTERPRISE_URL}/v1/reflex/check",
            headers={
                "Content-Type": "application/json",
                "X-API-Key": API_KEY
            },
            json={
                "scenario": scenario,
                "source": "demo-ui"
            },
            timeout=10
        )

        if response.status_code != 200:
            return f"โŒ Enterprise error {response.status_code}:\n{response.text}"

        data = response.json()

        return (
            f"๐Ÿง  Reflex Decision\n"
            f"-------------------\n"
            f"State: {data.get('state')}\n"
            f"Score: {data.get('score')}\n"
            f"Action: {data.get('action')}\n"
            f"Reason: {data.get('reason')}"
        )

    except Exception as e:
        return f"๐Ÿšจ Connection error:\n{str(e)}"


# โœ… CORRECTLY INDENTED UI
with gr.Blocks(title="Codex ReflexGuard Demo") as demo:
    gr.Markdown(
        "## ๐Ÿ›ก๏ธ Codex ReflexGuard\n"
        "**Enterprise Reflex Intelligence (Live Backend)**"
    )

    scenario = gr.Textbox(
        label="System Scenario",
        placeholder="e.g. override surge detected in control plane"
    )

    output = gr.Textbox(
        label="System Log",
        lines=8
    )

    run_btn = gr.Button("๐Ÿš€ Launch Reflex Check")

    run_btn.click(
        fn=run_reflex,
        inputs=scenario,
        outputs=output
    )

demo.launch()