File size: 1,895 Bytes
27dce05
 
ce94d65
 
27dce05
ce94d65
6eea3ca
27dce05
6eea3ca
 
27dce05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ce94d65
27dce05
 
ce94d65
27dce05
ce94d65
27dce05
ce94d65
 
27dce05
 
 
 
 
d38a78d
27dce05
d38a78d
 
27dce05
d38a78d
27dce05
 
d38a78d
6eea3ca
ce94d65
d38a78d
ce94d65
 
27dce05
ce94d65
 
27dce05
 
 
 
5563105
27dce05
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
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import gradio as gr
import numpy as np
import uvicorn

# ============================================================
#  RFT-Ω  HARMONIC  DEMONSTRATOR  —  PUBLIC  VALIDATION  API
# ============================================================

# --- Core FastAPI application ---
api = FastAPI(title="RFT-Ω Kernel Validation API",
              description="Public verification interface for RFT harmonic stability metrics.",
              version="1.0")

api.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

# --- Secure public endpoints --------------------------------
@api.get("/api/ping")
def ping():
    """Lightweight heartbeat for connectivity verification."""
    return {"ok": True, "message": "RFT-Ω API online and stable"}

@api.get("/api/metrics")
def metrics():
    """Return simulated QΩ and ζ_sync readings."""
    q_omega = float(np.random.uniform(0.82, 0.89))
    z_sync  = float(np.random.uniform(0.75, 0.88))
    return {
        "QΩ": round(q_omega, 3),
        "ζ_sync": round(z_sync, 3),
        "status": "nominal"
    }

# --- Gradio dashboard (for manual inspection) ----------------
def ui_fn(choice):
    if choice == "Ping":
        r = ping()
    else:
        r = metrics()
    return f"{r}"

demo = gr.Interface(
    fn=ui_fn,
    inputs=gr.Radio(["Ping", "Metrics"], label="Select endpoint"),
    outputs="text",
    title="RFT-Ω Harmonic Demo",
    description="Endpoints live at  /api/ping  and  /api/metrics  for JSON access."
)

# --- Combine FastAPI + Gradio -------------------------------
app = gr.mount_gradio_app(api, demo, path="/")

# --- Local launch (HF auto-runs this) ------------------------
if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=7860)