Update app.py
Browse files
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.
|
8 |
|
9 |
async def run_pipeline(idea: str) -> str:
|
10 |
"""
|
11 |
-
Runs
|
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("
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
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()
|