LordXido commited on
Commit
a437bca
·
verified ·
1 Parent(s): 11b34d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -14
app.py CHANGED
@@ -1,25 +1,47 @@
1
  import gradio as gr
2
- from codex.reflex_loop import run_reflex_engine
 
 
 
 
 
 
 
3
 
4
- def handle_input(username, task):
5
  try:
6
- code, result, steps, svg = run_reflex_engine(username, task)
7
- return code, str(result), "\n".join(steps), svg
 
 
 
 
 
 
 
 
 
 
8
  except Exception as e:
9
- return "", str(e), "", ""
 
10
 
11
- with gr.Blocks() as demo:
12
- gr.Markdown("# 🤖 Codex Reflex AGI v2")
 
13
 
14
  username = gr.Textbox(label="👤 Username")
15
  task = gr.Textbox(label="🎯 Task")
16
- run = gr.Button("⚡ Execute")
17
 
18
- code_out = gr.Code(label="🧠 Generated Code")
19
- result_out = gr.Textbox(label="📤 Result")
20
- plan_out = gr.Textbox(label="🧩 Task Plan")
21
- svg_out = gr.HTML(label="📊 Execution Flow")
 
22
 
23
- run.click(handle_input, [username, task], [code_out, result_out, plan_out, svg_out])
 
 
 
 
24
 
25
- demo.launch()
 
1
  import gradio as gr
2
+ import traceback
3
+ from llm_router import LLMRouter, AllProvidersFailed
4
+
5
+ router = LLMRouter()
6
+
7
+ def execute_task(username, task):
8
+ if not task.strip():
9
+ return "", "No task provided.", ""
10
 
 
11
  try:
12
+ code = router.generate_code(task)
13
+
14
+ local_scope = {}
15
+ exec(code, {}, local_scope)
16
+
17
+ result = local_scope.get("result", "Execution complete.")
18
+
19
+ return code, str(result), "Task executed successfully."
20
+
21
+ except AllProvidersFailed as e:
22
+ return "", f"All LLM providers failed: {str(e)}", "Failover exhausted."
23
+
24
  except Exception as e:
25
+ tb = traceback.format_exc()
26
+ return "", f"Execution error: {str(e)}", tb
27
 
28
+
29
+ with gr.Blocks() as app:
30
+ gr.Markdown("## 🤖 Codex Reflex AGI vΩΞ-R (Resilient Mode)")
31
 
32
  username = gr.Textbox(label="👤 Username")
33
  task = gr.Textbox(label="🎯 Task")
 
34
 
35
+ execute_btn = gr.Button(" Execute")
36
+
37
+ generated_code = gr.Code(label="🧠 Generated Code", language="python")
38
+ result = gr.Textbox(label="📦 Result")
39
+ log = gr.Textbox(label="🧩 Task Log")
40
 
41
+ execute_btn.click(
42
+ execute_task,
43
+ inputs=[username, task],
44
+ outputs=[generated_code, result, log]
45
+ )
46
 
47
+ app.launch()