Update deployer/gradio_generator.py
Browse files- deployer/gradio_generator.py +36 -67
deployer/gradio_generator.py
CHANGED
@@ -1,97 +1,66 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
import asyncio
|
4 |
import gradio as gr
|
5 |
-
|
6 |
from core_creator.voice_to_app import VoiceToAppCreator
|
7 |
from deployer.simulator_interface import VirtualRobot
|
8 |
from deployer.revenue_tracker import package_artifacts
|
9 |
|
10 |
-
|
11 |
"""
|
12 |
-
|
|
|
13 |
"""
|
14 |
creator = VoiceToAppCreator(idea)
|
15 |
assets = creator.run_pipeline()
|
16 |
title = assets.get("blueprint", {}).get("title", "<unknown>")
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
"""
|
21 |
-
Synchronous wrapper for Gradio: generate the app.
|
22 |
-
"""
|
23 |
-
return asyncio.run(_run_pipeline(idea))
|
24 |
-
|
25 |
-
def robot_behavior(user_input: str) -> str:
|
26 |
-
"""
|
27 |
-
Simulate robot action based on a user command.
|
28 |
-
"""
|
29 |
-
return VirtualRobot().perform_action(user_input)
|
30 |
|
31 |
-
def
|
32 |
"""
|
33 |
-
|
34 |
"""
|
35 |
-
|
36 |
-
return zip_path
|
37 |
|
38 |
-
def launch_gradio_app()
|
39 |
"""
|
40 |
-
|
41 |
"""
|
42 |
-
|
43 |
-
|
44 |
-
gr.Markdown(
|
45 |
-
"## π RoboSage \n"
|
46 |
-
"Generate your custom robot app and test it live."
|
47 |
-
)
|
48 |
|
49 |
with gr.Row():
|
50 |
-
|
51 |
-
|
52 |
-
# ββββββββββββββββββββββββββββ
|
53 |
-
with gr.Column(scale=1):
|
54 |
-
gr.Markdown("### 1οΈβ£ Generate App")
|
55 |
idea_input = gr.Textbox(
|
56 |
-
label="
|
57 |
-
placeholder="e.g
|
|
|
58 |
)
|
59 |
-
|
60 |
-
|
|
|
61 |
|
62 |
-
|
63 |
fn=deploy_callback,
|
64 |
-
inputs=
|
65 |
-
outputs=[
|
66 |
-
)
|
67 |
-
|
68 |
-
download_btn = gr.Button("π¦ Download App ZIP")
|
69 |
-
zip_out = gr.File(label="Your App ZIP")
|
70 |
-
|
71 |
-
download_btn.click(
|
72 |
-
fn=download_callback,
|
73 |
-
outputs=[zip_out]
|
74 |
)
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
label="Speak or Type Command",
|
83 |
-
placeholder="hello or say You rock!"
|
84 |
)
|
85 |
-
|
86 |
-
|
87 |
|
88 |
-
|
89 |
fn=robot_behavior,
|
90 |
-
inputs=
|
91 |
-
outputs=
|
92 |
)
|
93 |
|
94 |
return demo
|
95 |
-
|
96 |
-
if __name__ == "__main__":
|
97 |
-
launch_gradio_app().launch()
|
|
|
1 |
+
import os
|
|
|
|
|
2 |
import gradio as gr
|
|
|
3 |
from core_creator.voice_to_app import VoiceToAppCreator
|
4 |
from deployer.simulator_interface import VirtualRobot
|
5 |
from deployer.revenue_tracker import package_artifacts
|
6 |
|
7 |
+
def deploy_callback(idea: str):
|
8 |
"""
|
9 |
+
Generates the app based on the provided idea and packages it into a ZIP file.
|
10 |
+
Returns a status message and the path to the ZIP file.
|
11 |
"""
|
12 |
creator = VoiceToAppCreator(idea)
|
13 |
assets = creator.run_pipeline()
|
14 |
title = assets.get("blueprint", {}).get("title", "<unknown>")
|
15 |
+
zip_path = package_artifacts(assets)
|
16 |
+
status_msg = f"β
Generated app: {title}"
|
17 |
+
return status_msg, zip_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
def robot_behavior(command: str) -> str:
|
20 |
"""
|
21 |
+
Simulates robot action based on a text command.
|
22 |
"""
|
23 |
+
return VirtualRobot().perform_action(command)
|
|
|
24 |
|
25 |
+
def launch_gradio_app():
|
26 |
"""
|
27 |
+
Builds and returns the Gradio Blocks UI for the RoboSage app.
|
28 |
"""
|
29 |
+
with gr.Blocks() as demo:
|
30 |
+
gr.Markdown("# π€ RoboSage: Your Personal Robot App Generator")
|
|
|
|
|
|
|
|
|
31 |
|
32 |
with gr.Row():
|
33 |
+
with gr.Column():
|
34 |
+
gr.Markdown("### π οΈ Generate Your Robot App")
|
|
|
|
|
|
|
35 |
idea_input = gr.Textbox(
|
36 |
+
label="Enter your robot idea",
|
37 |
+
placeholder="e.g., A friendly greeting robot.",
|
38 |
+
lines=2
|
39 |
)
|
40 |
+
generate_button = gr.Button("Generate App")
|
41 |
+
status_output = gr.Textbox(label="Status", interactive=False)
|
42 |
+
download_output = gr.File(label="Download App ZIP")
|
43 |
|
44 |
+
generate_button.click(
|
45 |
fn=deploy_callback,
|
46 |
+
inputs=idea_input,
|
47 |
+
outputs=[status_output, download_output]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
)
|
49 |
|
50 |
+
with gr.Column():
|
51 |
+
gr.Markdown("### π€ Robot Simulator")
|
52 |
+
command_input = gr.Textbox(
|
53 |
+
label="Enter command",
|
54 |
+
placeholder="e.g., say Hello World!",
|
55 |
+
lines=1
|
|
|
|
|
56 |
)
|
57 |
+
send_button = gr.Button("Send Command")
|
58 |
+
response_output = gr.Textbox(label="Robot Response", interactive=False)
|
59 |
|
60 |
+
send_button.click(
|
61 |
fn=robot_behavior,
|
62 |
+
inputs=command_input,
|
63 |
+
outputs=response_output
|
64 |
)
|
65 |
|
66 |
return demo
|
|
|
|
|
|