Update deployer/gradio_generator.py
Browse files- deployer/gradio_generator.py +25 -36
deployer/gradio_generator.py
CHANGED
@@ -1,53 +1,42 @@
|
|
1 |
-
# gradio_generator.py - Gradio
|
2 |
|
3 |
import gradio as gr
|
4 |
from core_creator.voice_to_app import VoiceToAppCreator
|
5 |
|
6 |
-
def deploy_callback(voice_input
|
7 |
"""
|
8 |
-
|
9 |
"""
|
10 |
creator = VoiceToAppCreator(voice_input)
|
11 |
app_package = creator.run_pipeline()
|
12 |
return app_package
|
13 |
|
14 |
-
def robot_behavior(
|
15 |
"""
|
16 |
-
|
17 |
"""
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
def process_input(user_input):
|
38 |
-
app_package = deploy_callback(user_input)
|
39 |
-
return (
|
40 |
-
app_package.get("intent", ""),
|
41 |
-
app_package["blueprint"].get("description", ""),
|
42 |
-
app_package.get("code", ""),
|
43 |
-
app_package.get("assets", {})
|
44 |
)
|
45 |
|
46 |
-
|
47 |
-
fn=process_input,
|
48 |
-
inputs=voice_input,
|
49 |
-
outputs=[intent_output, description_output, code_output, assets_output]
|
50 |
-
)
|
51 |
|
52 |
if __name__ == "__main__":
|
|
|
53 |
demo.launch()
|
|
|
1 |
+
# gradio_generator.py - Gradio UI for Voice-to-App Creator
|
2 |
|
3 |
import gradio as gr
|
4 |
from core_creator.voice_to_app import VoiceToAppCreator
|
5 |
|
6 |
+
def deploy_callback(voice_input):
|
7 |
"""
|
8 |
+
Callback function to process voice input and generate the robot app package.
|
9 |
"""
|
10 |
creator = VoiceToAppCreator(voice_input)
|
11 |
app_package = creator.run_pipeline()
|
12 |
return app_package
|
13 |
|
14 |
+
def robot_behavior():
|
15 |
"""
|
16 |
+
Defines the Gradio interface for the Voice-to-App Creator.
|
17 |
"""
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
gr.Markdown("# π€ Voice-to-App Creator")
|
20 |
+
gr.Markdown("Describe your robot idea, and we'll generate an app for it!")
|
21 |
+
|
22 |
+
with gr.Row():
|
23 |
+
voice_input = gr.Textbox(
|
24 |
+
label="Your Robot Idea",
|
25 |
+
placeholder="e.g., Build a robot that teaches kids to brush their teeth with fun animations.",
|
26 |
+
lines=3
|
27 |
+
)
|
28 |
+
submit_button = gr.Button("Generate App")
|
29 |
+
|
30 |
+
output = gr.JSON(label="Generated App Package")
|
31 |
+
|
32 |
+
submit_button.click(
|
33 |
+
fn=deploy_callback,
|
34 |
+
inputs=voice_input,
|
35 |
+
outputs=output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
)
|
37 |
|
38 |
+
return demo
|
|
|
|
|
|
|
|
|
39 |
|
40 |
if __name__ == "__main__":
|
41 |
+
demo = robot_behavior()
|
42 |
demo.launch()
|