Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,111 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from datetime import datetime
|
| 3 |
-
|
| 4 |
from core_engine import run_engine
|
| 5 |
-
from ingest import normalize_input
|
| 6 |
-
from utils import validate_api_key
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 10 |
-
# CodexFlow ΩΠExecution Bridge
|
| 11 |
-
# βββββββββββββββββββββββββββββββββββββββββββββ
|
| 12 |
-
|
| 13 |
-
def codexflow_execute(
|
| 14 |
-
api_key: str,
|
| 15 |
-
commodity: str,
|
| 16 |
-
physical_anchor: float,
|
| 17 |
-
reporting_lag: int,
|
| 18 |
-
use_live_feed: bool
|
| 19 |
-
):
|
| 20 |
-
# --- Security gate ---
|
| 21 |
-
if not validate_api_key(api_key):
|
| 22 |
-
return {
|
| 23 |
-
"status": "ERROR",
|
| 24 |
-
"message": "Invalid or missing API key"
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
# --- Normalize input ---
|
| 28 |
-
payload = normalize_input(
|
| 29 |
-
commodity=commodity,
|
| 30 |
-
physical_anchor=physical_anchor,
|
| 31 |
-
reporting_lag=reporting_lag,
|
| 32 |
-
live_feed=use_live_feed
|
| 33 |
-
)
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
"
|
| 40 |
-
"engine": "CodexFlow Ξ©Ξ",
|
| 41 |
-
"timestamp": datetime.utcnow().isoformat() + "Z",
|
| 42 |
-
"input": payload,
|
| 43 |
-
"output": result
|
| 44 |
}
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
Harmonizes global economic signals by correcting:
|
| 59 |
-
β’ reporting lag
|
| 60 |
-
β’ synthetic distortion
|
| 61 |
-
β’ physical supply mismatch
|
| 62 |
-
"""
|
| 63 |
-
)
|
| 64 |
-
|
| 65 |
-
api_key = gr.Textbox(
|
| 66 |
-
label="API Key",
|
| 67 |
-
type="password",
|
| 68 |
-
placeholder="Enter API key"
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
commodity = gr.Dropdown(
|
| 72 |
-
["Gold", "Iron Ore", "Oil", "Copper"],
|
| 73 |
-
value="Gold",
|
| 74 |
-
label="Commodity"
|
| 75 |
-
)
|
| 76 |
-
|
| 77 |
-
physical_anchor = gr.Number(
|
| 78 |
-
label="Physical Anchor",
|
| 79 |
-
value=950
|
| 80 |
-
)
|
| 81 |
-
|
| 82 |
-
reporting_lag = gr.Slider(
|
| 83 |
-
minimum=0,
|
| 84 |
-
maximum=30,
|
| 85 |
-
value=7,
|
| 86 |
-
step=1,
|
| 87 |
-
label="Reporting Lag (Days)"
|
| 88 |
-
)
|
| 89 |
-
|
| 90 |
-
live_feed = gr.Checkbox(
|
| 91 |
-
value=True,
|
| 92 |
-
label="Use Live Exchange Feed"
|
| 93 |
-
)
|
| 94 |
-
|
| 95 |
-
execute_btn = gr.Button("Execute")
|
| 96 |
-
output = gr.JSON(label="Result")
|
| 97 |
-
|
| 98 |
-
execute_btn.click(
|
| 99 |
-
fn=codexflow_execute,
|
| 100 |
-
inputs=[
|
| 101 |
-
api_key,
|
| 102 |
-
commodity,
|
| 103 |
-
physical_anchor,
|
| 104 |
-
reporting_lag,
|
| 105 |
-
live_feed
|
| 106 |
-
],
|
| 107 |
-
outputs=output
|
| 108 |
-
)
|
| 109 |
|
| 110 |
if __name__ == "__main__":
|
| 111 |
-
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
from core_engine import run_engine
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
def execute(commodity, anchor, lag):
|
| 5 |
+
payload = {
|
| 6 |
+
"commodity": commodity,
|
| 7 |
+
"physical_anchor": anchor,
|
| 8 |
+
"reporting_lag": lag
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
}
|
| 10 |
+
return run_engine(payload)
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=execute,
|
| 14 |
+
inputs=[
|
| 15 |
+
gr.Dropdown(["Gold", "Iron Ore", "Oil"], label="Commodity"),
|
| 16 |
+
gr.Number(value=950, label="Physical Anchor"),
|
| 17 |
+
gr.Slider(1, 30, value=7, label="Reporting Lag (days)")
|
| 18 |
+
],
|
| 19 |
+
outputs=gr.JSON(label="Result"),
|
| 20 |
+
title="CodexFlow Ξ©Ξ",
|
| 21 |
+
description="Autonomous Economic Reflex Operating System"
|
| 22 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
if __name__ == "__main__":
|
| 25 |
+
iface.launch()
|