LordXido commited on
Commit
8fdb8ad
·
verified ·
1 Parent(s): c730014

Upload 5 files

Browse files
Files changed (5) hide show
  1. agent_loop.py +8 -0
  2. app.py +47 -0
  3. codexmesh_config.yaml +6 -0
  4. requirements.txt +5 -0
  5. ws_router.py +12 -0
agent_loop.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ import time
2
+ from jarvis_x_engine_vHF import run_codex_loop
3
+
4
+ def reflex_loop():
5
+ while True:
6
+ print("🌀 ReflexAgent: Executing default spiral intent...")
7
+ run_codex_loop("Render a spiral")
8
+ time.sleep(10) # Auto-loop every 10 seconds
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_vHF import run_codex_loop
8
+ from ws_router import router as ws_router
9
+ from agent_loop import reflex_loop
10
+
11
+ # === FastAPI App with WebSocket support ===
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 UI ===
24
+ def launch_command(command):
25
+ result = run_codex_loop(command)
26
+ return result, "OK", "<svg><!-- Spiral Render --></svg>"
27
+
28
+ with gr.Blocks() as demo:
29
+ with gr.Row():
30
+ command_input = gr.Textbox(label="Command")
31
+ submit_btn = gr.Button("Execute")
32
+ with gr.Row():
33
+ response = gr.Textbox(label="Response")
34
+ log_output = gr.Textbox(label="Log")
35
+ svg_preview = gr.HTML(label="SVG Output")
36
+
37
+ submit_btn.click(fn=launch_command, inputs=[command_input], outputs=[response, log_output, svg_preview])
38
+
39
+ # === Launch ReflexAgent in background ===
40
+ threading.Thread(target=reflex_loop, daemon=True).start()
41
+
42
+ # === Mount Gradio on FastAPI ===
43
+ app = gr.mount_gradio_app(app, demo, path="/")
44
+
45
+ # === Dev server entry point ===
46
+ if __name__ == "__main__":
47
+ uvicorn.run(app, host="0.0.0.0", port=7860)
codexmesh_config.yaml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ relay_node: "https://codexmesh.node/receive"
2
+ auth_token: "YOUR_CODex_TOKEN_HERE"
3
+ timeout_sec: 5
4
+ dispatch_fields:
5
+ - spiral_render
6
+ - reflex_log
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ fastapi
3
+ uvicorn
4
+ websockets
5
+ python-multipart
ws_router.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter, WebSocket
2
+ from jarvis_x_engine_vHF import run_codex_loop
3
+
4
+ router = APIRouter()
5
+
6
+ @router.websocket("/ws")
7
+ async def websocket_endpoint(websocket: WebSocket):
8
+ await websocket.accept()
9
+ while True:
10
+ data = await websocket.receive_text()
11
+ response = run_codex_loop(data)
12
+ await websocket.send_text(f"Codex Response: {response}")