LordXido commited on
Commit
03a1032
Β·
verified Β·
1 Parent(s): d9323ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -36
app.py CHANGED
@@ -2,81 +2,52 @@ import gradio as gr
2
  from fastapi import FastAPI
3
  from fastapi.middleware.cors import CORSMiddleware
4
 
5
- # Local Codex imports
6
  from omega_memory import log_event
7
  from agent_loop import reflex_loop
8
  from codexmesh_sync import CodexMeshSync
9
  from CodexQuantum3D_Engine import simulate_quantum_visual
10
 
11
- # --- Optional WebSocket Router ---
12
- # Safe import: won't crash if file is missing
13
  try:
14
  from ws_router import router as ws_router
15
  WS_AVAILABLE = True
16
  except Exception:
17
  WS_AVAILABLE = False
18
 
19
- # --- Boot CodexMesh Sync ---
20
- try:
21
- CodexMeshSync()
22
- print("πŸ” CodexMesh Node Alive β€” Heartbeat Sync")
23
- except Exception as e:
24
- print("⚠ CodexMesh Sync failed:", e)
25
 
26
- # --- Reflex Execution Wrapper ---
27
  def launch_command(user_input: str):
28
  try:
29
  if not user_input.strip():
30
  return "No intent provided.", "Ξ©-log skipped.", None
31
 
32
- # Run reflex loop
33
  response, log = reflex_loop(user_input)
34
-
35
- # Generate quantum visual
36
  img = simulate_quantum_visual(user_input)
37
 
38
  return response, str(log), img
39
 
40
  except Exception as e:
41
- err_msg = f"Execution error: {str(e)}"
42
- print("❌ Reflex Failure:", err_msg)
43
- return err_msg, "Ξ©-memory failure", None
44
 
45
 
46
- # --- Gradio UI ---
47
  with gr.Blocks() as interface:
48
- gr.Markdown("## 🧠 Codex Reality Engine – Phase IX+Ξ© Quantum Reflex")
49
-
50
- user_input = gr.Textbox(
51
- label="πŸ” Intent",
52
- placeholder="Enter your intent (e.g., Render a harmonic spiral field)"
53
- )
54
 
 
55
  btn = gr.Button("⚑ Run Reflex Engine")
56
 
57
  output1 = gr.Textbox(label="πŸ“€ Response")
58
  output2 = gr.Textbox(label="🧾 Ξ©-Memory Log")
59
  output3 = gr.Image(type="pil", label="πŸŒ€ Quantum Visual Output")
60
 
61
- btn.click(
62
- fn=launch_command,
63
- inputs=[user_input],
64
- outputs=[output1, output2, output3]
65
- )
66
 
67
 
68
- # --- FastAPI Host ---
69
  app = FastAPI()
70
-
71
- # Mount Gradio app
72
  app = gr.mount_gradio_app(app, interface, path="/")
73
 
74
- # Add WebSocket routes if present
75
  if WS_AVAILABLE:
76
  app.include_router(ws_router)
77
- print("πŸ›° WebSocket Router Online")
78
 
79
- # CORS middleware
80
  app.add_middleware(
81
  CORSMiddleware,
82
  allow_origins=["*"],
@@ -85,8 +56,6 @@ app.add_middleware(
85
  allow_headers=["*"]
86
  )
87
 
88
- # --- HF Runtime Launch ---
89
  if __name__ == "__main__":
90
  import uvicorn
91
- print("πŸš€ Codex Runtime Booting on :7860")
92
  uvicorn.run(app, host="0.0.0.0", port=7860)
 
2
  from fastapi import FastAPI
3
  from fastapi.middleware.cors import CORSMiddleware
4
 
 
5
  from omega_memory import log_event
6
  from agent_loop import reflex_loop
7
  from codexmesh_sync import CodexMeshSync
8
  from CodexQuantum3D_Engine import simulate_quantum_visual
9
 
 
 
10
  try:
11
  from ws_router import router as ws_router
12
  WS_AVAILABLE = True
13
  except Exception:
14
  WS_AVAILABLE = False
15
 
16
+ CodexMeshSync()
 
 
 
 
 
17
 
 
18
  def launch_command(user_input: str):
19
  try:
20
  if not user_input.strip():
21
  return "No intent provided.", "Ξ©-log skipped.", None
22
 
 
23
  response, log = reflex_loop(user_input)
 
 
24
  img = simulate_quantum_visual(user_input)
25
 
26
  return response, str(log), img
27
 
28
  except Exception as e:
29
+ return f"Execution error: {e}", "Ξ©-memory failure", None
 
 
30
 
31
 
 
32
  with gr.Blocks() as interface:
33
+ gr.Markdown("## 🧠 Codex Reality Engine – Phase IX+Ξ© Quantum Reflex (Streaming Node)")
 
 
 
 
 
34
 
35
+ user_input = gr.Textbox(label="πŸ” Intent")
36
  btn = gr.Button("⚑ Run Reflex Engine")
37
 
38
  output1 = gr.Textbox(label="πŸ“€ Response")
39
  output2 = gr.Textbox(label="🧾 Ξ©-Memory Log")
40
  output3 = gr.Image(type="pil", label="πŸŒ€ Quantum Visual Output")
41
 
42
+ btn.click(fn=launch_command, inputs=[user_input], outputs=[output1, output2, output3])
 
 
 
 
43
 
44
 
 
45
  app = FastAPI()
 
 
46
  app = gr.mount_gradio_app(app, interface, path="/")
47
 
 
48
  if WS_AVAILABLE:
49
  app.include_router(ws_router)
 
50
 
 
51
  app.add_middleware(
52
  CORSMiddleware,
53
  allow_origins=["*"],
 
56
  allow_headers=["*"]
57
  )
58
 
 
59
  if __name__ == "__main__":
60
  import uvicorn
 
61
  uvicorn.run(app, host="0.0.0.0", port=7860)