Update app.py
Browse files
app.py
CHANGED
@@ -1,46 +1,49 @@
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import asyncio
|
3 |
-
from core_creator.voice_to_app import VoiceToAppCreator
|
4 |
-
from deployer.gradio_generator import launch_gradio_app
|
5 |
-
import os
|
6 |
-
import logging
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
return f"β
{title} launched successfully!"
|
23 |
-
except Exception as e:
|
24 |
-
logging.error(f"Processing failed: {e}")
|
25 |
-
return f"β Error: {str(e)}"
|
26 |
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
gr.
|
31 |
-
|
32 |
-
|
33 |
-
status_output = gr.Textbox(label="Status", interactive=False)
|
34 |
-
|
35 |
-
gr.Button("Create").click(
|
36 |
-
fn=lambda idea: asyncio.run(process_idea(idea)),
|
37 |
-
inputs=idea_input,
|
38 |
-
outputs=status_output
|
39 |
-
)
|
40 |
-
|
41 |
-
return launcher
|
42 |
|
|
|
43 |
if __name__ == "__main__":
|
44 |
-
|
45 |
-
app = create_launcher()
|
46 |
-
app.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
1 |
+
# app.py - Unified RoboSage Deployer & Robot Simulator (CPU & Spaces-compatible)
|
2 |
+
import os
|
3 |
+
from core_creator.voice_to_app import VoiceToAppCreator
|
4 |
+
from deployer.simulator_interface import VirtualRobot
|
5 |
import gradio as gr
|
6 |
import asyncio
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
# Pipeline runner: generates app blueprint and code
|
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 |
+
# Synchronous wrapper for Gradio use
|
19 |
+
def deploy_callback(idea: str) -> str:
|
20 |
+
return asyncio.run(run_pipeline(idea))
|
21 |
+
|
22 |
+
# Robot simulator callback
|
23 |
+
def robot_behavior(user_input: str) -> str:
|
24 |
+
"""
|
25 |
+
Simulate robot action based on user text.
|
26 |
+
"""
|
27 |
+
return VirtualRobot().perform_action(user_input)
|
28 |
|
29 |
+
# Build unified Gradio interface
|
30 |
+
with gr.Blocks() as demo:
|
31 |
+
gr.Markdown("""# π RoboSage
|
32 |
+
Generate your custom robot app and test it live in one interface.""")
|
33 |
+
with gr.Column():
|
34 |
+
gr.Markdown("## 1οΈβ£ Generate App")
|
35 |
+
user_idea = gr.Textbox(label="Your Robot Idea", placeholder="e.g. A friendly greeting robot.")
|
36 |
+
deploy_btn = gr.Button("Generate App", key="deploy-app-btn")
|
37 |
+
deploy_status = gr.Textbox(label="Status")
|
38 |
+
deploy_btn.click(fn=deploy_callback, inputs=[user_idea], outputs=[deploy_status])
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
with gr.Column():
|
41 |
+
gr.Markdown("## 2οΈβ£ Robot Simulator")
|
42 |
+
robot_input = gr.Textbox(label="Speak or Type Command", placeholder="hello or say You rock!")
|
43 |
+
robot_btn = gr.Button("Send", key="simulate-btn")
|
44 |
+
robot_output = gr.Textbox(label="Robot Response", lines=4)
|
45 |
+
robot_btn.click(fn=robot_behavior, inputs=[robot_input], outputs=[robot_output])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
+
# Launch the complete app
|
48 |
if __name__ == "__main__":
|
49 |
+
demo.launch()
|
|
|
|