LordXido commited on
Commit
5776437
Β·
verified Β·
1 Parent(s): 783e5b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -44
app.py CHANGED
@@ -1,51 +1,33 @@
 
1
  import gradio as gr
2
  from fastapi import FastAPI
3
  from fastapi.middleware.cors import CORSMiddleware
4
- import uvicorn
5
- import threading
6
 
7
- from jarvis_x_engine import run_codex_loop
8
- from ws_router import router as ws_router
9
  from agent_loop import reflex_loop
10
-
11
- # === FastAPI backend app ===
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  app = FastAPI()
 
13
  app.include_router(ws_router)
14
-
15
- app.add_middleware(
16
- CORSMiddleware,
17
- allow_origins=["*"],
18
- allow_credentials=True,
19
- allow_methods=["*"],
20
- allow_headers=["*"],
21
- )
22
-
23
- # === Gradio Command Execution ===
24
- def launch_command(command):
25
- try:
26
- result = run_codex_loop(command)
27
- svg = "<svg width='300' height='300'><circle cx='150' cy='150' r='100' stroke='blue' stroke-width='3' fill='none' /></svg>"
28
- return result, f"Command: {command} executed.", svg
29
- except Exception as e:
30
- return str(e), "Execution failed.", "<svg><!-- error --></svg>"
31
-
32
- # === Gradio UI ===
33
- with gr.Blocks() as demo:
34
- with gr.Row():
35
- command_input = gr.Textbox(label="Command")
36
- submit_btn = gr.Button("Execute")
37
- with gr.Row():
38
- response = gr.Textbox(label="Response")
39
- log_output = gr.Textbox(label="Log")
40
- svg_preview = gr.HTML(label="SVG Preview")
41
-
42
- submit_btn.click(fn=launch_command, inputs=[command_input], outputs=[response, log_output, svg_preview])
43
-
44
- # === Reflex Agent Thread ===
45
- threading.Thread(target=reflex_loop, daemon=True).start()
46
-
47
- # === Mount Gradio into FastAPI ===
48
- app = gr.mount_gradio_app(app, demo, path="/")
49
-
50
- if __name__ == "__main__":
51
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
1
+
2
  import gradio as gr
3
  from fastapi import FastAPI
4
  from fastapi.middleware.cors import CORSMiddleware
 
 
5
 
6
+ from omega_memory import log_event
 
7
  from agent_loop import reflex_loop
8
+ from ws_router import router as ws_router
9
+ from codexmesh_sync import CodexMeshSync
10
+
11
+ # ── Start CodexMesh Node Sync ──
12
+ CodexMeshSync()
13
+
14
+ # ── Gradio Interface ──
15
+ def launch_command(user_input):
16
+ response, log = reflex_loop(user_input)
17
+ svg = f"<svg width='300' height='200'><text x='10' y='50' font-size='18'>Response: {response}</text></svg>"
18
+ return response, str(log), svg
19
+
20
+ with gr.Blocks() as interface:
21
+ gr.Markdown("## 🧠 Codex Reality Engine – Phase VI+ (Ξ©Mesh)")
22
+ user_input = gr.Textbox(label="πŸ” Intent")
23
+ btn = gr.Button("⚑ Run Reflex Engine")
24
+ output1 = gr.Textbox(label="πŸ“€ Response")
25
+ output2 = gr.Textbox(label="🧾 Ω-Memory Log")
26
+ output3 = gr.HTML(label="πŸŒ€ SVG Output")
27
+ btn.click(fn=launch_command, inputs=[user_input], outputs=[output1, output2, output3])
28
+
29
+ # ── FastAPI Mount ──
30
  app = FastAPI()
31
+ app = gr.mount_gradio_app(app, interface, path="/")
32
  app.include_router(ws_router)
33
+ app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"])