RFTSystems commited on
Commit
c064364
·
verified ·
1 Parent(s): 76760b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -39
app.py CHANGED
@@ -1,62 +1,36 @@
1
- from fastapi import FastAPI
2
- from fastapi.middleware.cors import CORSMiddleware
3
  import gradio as gr
4
  import numpy as np
5
- import uvicorn
6
 
7
  # ============================================================
8
- # RFT-Ω HARMONIC DEMONSTRATOR — PUBLIC VALIDATION API
 
9
  # ============================================================
10
 
11
- # --- Core FastAPI application ---
12
- api = FastAPI(title="RFT-Ω Kernel Validation API",
13
- description="Public verification interface for RFT harmonic stability metrics.",
14
- version="1.0")
15
-
16
- api.add_middleware(
17
- CORSMiddleware,
18
- allow_origins=["*"],
19
- allow_credentials=True,
20
- allow_methods=["*"],
21
- allow_headers=["*"],
22
- )
23
-
24
- # --- Secure public endpoints --------------------------------
25
- @api.get("/api/ping")
26
  def ping():
27
- """Lightweight heartbeat for connectivity verification."""
28
  return {"ok": True, "message": "RFT-Ω API online and stable"}
29
 
30
- @api.get("/api/metrics")
31
  def metrics():
32
- """Return simulated QΩ and ζ_sync readings."""
33
  q_omega = float(np.random.uniform(0.82, 0.89))
34
  z_sync = float(np.random.uniform(0.75, 0.88))
35
- return {
36
- "QΩ": round(q_omega, 3),
37
- "ζ_sync": round(z_sync, 3),
38
- "status": "nominal"
39
- }
40
 
41
- # --- Gradio dashboard (for manual inspection) ----------------
42
  def ui_fn(choice):
43
  if choice == "Ping":
44
- r = ping()
 
 
45
  else:
46
- r = metrics()
47
- return f"{r}"
48
 
49
  demo = gr.Interface(
50
  fn=ui_fn,
51
  inputs=gr.Radio(["Ping", "Metrics"], label="Select endpoint"),
52
- outputs="text",
53
- title="RFT-Ω Harmonic Demo",
54
- description="Endpoints live at /api/ping and /api/metrics for JSON access."
55
  )
56
 
57
- # --- Combine FastAPI + Gradio -------------------------------
58
- app = gr.mount_gradio_app(api, demo, path="/")
59
-
60
- # --- Local launch (HF auto-runs this) ------------------------
61
  if __name__ == "__main__":
62
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
1
  import gradio as gr
2
  import numpy as np
 
3
 
4
  # ============================================================
5
+ # RFT-Ω HARMONIC VALIDATION INTERFACE
6
+ # Simplified Gradio build — public demonstration of QΩ / ζ_sync stability
7
  # ============================================================
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  def ping():
10
+ """Return a JSON-formatted heartbeat."""
11
  return {"ok": True, "message": "RFT-Ω API online and stable"}
12
 
 
13
  def metrics():
14
+ """Return simulated QΩ and ζ_sync metrics."""
15
  q_omega = float(np.random.uniform(0.82, 0.89))
16
  z_sync = float(np.random.uniform(0.75, 0.88))
17
+ return {"QΩ": round(q_omega, 3), "ζ_sync": round(z_sync, 3), "status": "nominal"}
 
 
 
 
18
 
 
19
  def ui_fn(choice):
20
  if choice == "Ping":
21
+ return ping()
22
+ elif choice == "Metrics":
23
+ return metrics()
24
  else:
25
+ return {"error": "Invalid selection"}
 
26
 
27
  demo = gr.Interface(
28
  fn=ui_fn,
29
  inputs=gr.Radio(["Ping", "Metrics"], label="Select endpoint"),
30
+ outputs="json",
31
+ title="RFT-Ω Harmonic Validation Interface",
32
+ description="Select *Ping* or *Metrics* to view live JSON results."
33
  )
34
 
 
 
 
 
35
  if __name__ == "__main__":
36
+ demo.launch()