Update deployer/gradio_generator.py
Browse files- deployer/gradio_generator.py +23 -15
deployer/gradio_generator.py
CHANGED
|
@@ -1,23 +1,31 @@
|
|
| 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(
|
| 7 |
-
creator = VoiceToAppCreator(
|
| 8 |
app_package = creator.run_pipeline()
|
| 9 |
-
return app_package["
|
| 10 |
|
| 11 |
def robot_behavior():
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
fn=
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# gradio_generator.py - Launches the Gradio interface for robot apps
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
+
import asyncio
|
| 5 |
from core_creator.voice_to_app import VoiceToAppCreator
|
| 6 |
|
| 7 |
+
def deploy_callback(voice_input):
|
| 8 |
+
creator = VoiceToAppCreator(voice_input)
|
| 9 |
app_package = creator.run_pipeline()
|
| 10 |
+
return app_package["blueprint"], app_package["code"]
|
| 11 |
|
| 12 |
def robot_behavior():
|
| 13 |
+
with gr.Blocks() as demo:
|
| 14 |
+
gr.Markdown("## 🤖 Voice-to-Robot App Generator")
|
| 15 |
+
voice_input = gr.Textbox(label="Describe your robot idea")
|
| 16 |
+
blueprint_output = gr.JSON(label="App Blueprint")
|
| 17 |
+
code_output = gr.Code(label="Generated Code", language="python")
|
| 18 |
+
generate_button = gr.Button("Generate App")
|
| 19 |
|
| 20 |
+
def on_click(voice_input):
|
| 21 |
+
return deploy_callback(voice_input)
|
| 22 |
+
|
| 23 |
+
generate_button.click(fn=on_click, inputs=voice_input, outputs=[blueprint_output, code_output])
|
| 24 |
+
|
| 25 |
+
# Ensure an event loop is available
|
| 26 |
+
try:
|
| 27 |
+
asyncio.get_event_loop()
|
| 28 |
+
except RuntimeError:
|
| 29 |
+
asyncio.set_event_loop(asyncio.new_event_loop())
|
| 30 |
+
|
| 31 |
+
demo.launch()
|