mgbam commited on
Commit
798d95e
·
verified ·
1 Parent(s): 5d3be0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -42
app.py CHANGED
@@ -1,63 +1,59 @@
1
- # app.py
2
- # Unified RoboSage Deployer & Simulator (CPU & Spaces-compatible)
3
 
4
  import asyncio
5
  import gradio as gr
6
  from core_creator.voice_to_app import VoiceToAppCreator
7
- from deployer.simulator_interface import VirtualRobot
8
 
9
  async def run_pipeline(idea: str) -> str:
10
  """
11
- Runs the voice-to-app pipeline and returns a status message.
12
  """
13
  creator = VoiceToAppCreator(idea)
14
  assets = creator.run_pipeline()
15
  title = assets.get("blueprint", {}).get("title", "<unknown>")
16
  return f"✅ Generated app: {title}"
17
 
 
 
18
  def deploy_callback(idea: str) -> str:
19
- """
20
- Synchronous wrapper for Gradio.
21
- """
22
  return asyncio.run(run_pipeline(idea))
23
 
24
- def robot_behavior(user_input: str) -> str:
25
- """
26
- Simulate robot action based on user text.
27
- """
28
- return VirtualRobot().perform_action(user_input)
29
-
30
  # Build unified Gradio interface
31
  with gr.Blocks() as demo:
32
- gr.Markdown("# 🚀 RoboSage\nGenerate your custom robot app and test it live.")
33
-
34
- with gr.Column():
35
- gr.Markdown("## 1️⃣ Generate App")
36
- user_idea = gr.Textbox(
37
- label="Your Robot Idea",
38
- placeholder="e.g. A friendly greeting robot."
39
- )
40
- deploy_btn = gr.Button("Generate App", key="deploy-app-btn")
41
- deploy_status = gr.Textbox(label="Status")
42
- deploy_btn.click(
43
- fn=deploy_callback,
44
- inputs=[user_idea],
45
- outputs=[deploy_status]
46
- )
47
-
48
- with gr.Column():
49
- gr.Markdown("## 2️⃣ Robot Simulator")
50
- robot_input = gr.Textbox(
51
- label="Speak or Type Command",
52
- placeholder="hello or say You rock!"
53
- )
54
- robot_btn = gr.Button("Send", key="simulate-btn")
55
- robot_output = gr.Textbox(label="Robot Response", lines=4)
56
- robot_btn.click(
57
- fn=robot_behavior,
58
- inputs=[robot_input],
59
- outputs=[robot_output]
60
- )
 
 
 
 
61
 
62
  if __name__ == "__main__":
63
  demo.launch()
 
1
+ # app.py - Unified RoboSage Deployer & Simulator (CPU & Spaces-compatible)
 
2
 
3
  import asyncio
4
  import gradio as gr
5
  from core_creator.voice_to_app import VoiceToAppCreator
6
+ from deployer.gradio_generator import robot_behavior, launch_gradio_app
7
 
8
  async def run_pipeline(idea: str) -> str:
9
  """
10
+ Runs voice-to-app pipeline and returns a status message.
11
  """
12
  creator = VoiceToAppCreator(idea)
13
  assets = creator.run_pipeline()
14
  title = assets.get("blueprint", {}).get("title", "<unknown>")
15
  return f"✅ Generated app: {title}"
16
 
17
+ # Synchronous wrapper for Gradio
18
+
19
  def deploy_callback(idea: str) -> str:
 
 
 
20
  return asyncio.run(run_pipeline(idea))
21
 
 
 
 
 
 
 
22
  # Build unified Gradio interface
23
  with gr.Blocks() as demo:
24
+ gr.Markdown("""
25
+ # 🚀 RoboSage
26
+ Generate your custom robot app and test it live.
27
+ """)
28
+
29
+ with gr.Row():
30
+ with gr.Column():
31
+ gr.Markdown("## 1️⃣ Generate App")
32
+ user_idea = gr.Textbox(
33
+ label="Your Robot Idea",
34
+ placeholder="e.g. A friendly greeting robot."
35
+ )
36
+ deploy_btn = gr.Button("Generate App", key="deploy-app-btn")
37
+ deploy_status = gr.Textbox(label="Status", interactive=False)
38
+ deploy_btn.click(
39
+ fn=deploy_callback,
40
+ inputs=[user_idea],
41
+ outputs=[deploy_status]
42
+ )
43
+
44
+ with gr.Column():
45
+ gr.Markdown("## 2️⃣ Robot Simulator")
46
+ robot_input = gr.Textbox(
47
+ label="Command",
48
+ placeholder="hello or say You rock!"
49
+ )
50
+ robot_btn = gr.Button("Send", key="simulate-btn")
51
+ robot_output = gr.Textbox(label="Robot Response", lines=4, interactive=False)
52
+ robot_btn.click(
53
+ fn=robot_behavior,
54
+ inputs=[robot_input],
55
+ outputs=[robot_output]
56
+ )
57
 
58
  if __name__ == "__main__":
59
  demo.launch()