Update deployer/gradio_generator.py
Browse files- deployer/gradio_generator.py +16 -31
deployer/gradio_generator.py
CHANGED
|
@@ -1,42 +1,27 @@
|
|
| 1 |
-
# gradio_generator.py - Gradio UI for
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
from core_creator.voice_to_app import VoiceToAppCreator
|
| 5 |
|
| 6 |
-
def deploy_callback(
|
| 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 |
-
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 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
lines=3
|
| 27 |
-
)
|
| 28 |
-
submit_button = gr.Button("Generate App")
|
| 29 |
-
|
| 30 |
-
output = gr.JSON(label="Generated App Package")
|
| 31 |
|
| 32 |
-
|
| 33 |
-
fn=deploy_callback,
|
| 34 |
-
inputs=voice_input,
|
| 35 |
-
outputs=output
|
| 36 |
-
)
|
| 37 |
|
| 38 |
-
|
| 39 |
|
| 40 |
if __name__ == "__main__":
|
| 41 |
-
|
| 42 |
-
demo.launch()
|
|
|
|
| 1 |
+
# gradio_generator.py - Launches the Gradio UI for robot app deployment
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
from core_creator.voice_to_app import VoiceToAppCreator
|
| 5 |
|
| 6 |
+
def deploy_callback(user_input: str) -> dict:
|
| 7 |
+
creator = VoiceToAppCreator(user_input)
|
| 8 |
+
return creator.run_pipeline()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
def robot_behavior(user_input: str) -> str:
|
| 11 |
+
result = deploy_callback(user_input)
|
| 12 |
+
return result.get("code", "No code generated.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
def launch_gradio_interface():
|
| 15 |
+
with gr.Blocks() as demo:
|
| 16 |
+
gr.Markdown("# 🤖 Voice-to-Robot App Generator")
|
| 17 |
with gr.Row():
|
| 18 |
+
input_box = gr.Textbox(label="Describe your robot idea", placeholder="e.g., A robot that helps kids brush their teeth.")
|
| 19 |
+
output_box = gr.Code(label="Generated Code", language="python")
|
| 20 |
+
submit_btn = gr.Button("Generate App")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
+
submit_btn.click(fn=robot_behavior, inputs=input_box, outputs=output_box)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
demo.launch()
|
| 25 |
|
| 26 |
if __name__ == "__main__":
|
| 27 |
+
launch_gradio_interface()
|
|
|