|
import os |
|
import gradio as gr |
|
from deployer.gradio_generator import deploy_callback, robot_behavior |
|
|
|
def main(): |
|
|
|
custom_css = """ |
|
.gradio-container { max-width: 900px; margin: auto; } |
|
.section-header { margin-top: 1.5em; } |
|
""" |
|
|
|
with gr.Blocks(css=custom_css) as demo: |
|
gr.Markdown("# π RoboSage\nGenerate your custom robot app, download it, then test it live.") |
|
|
|
|
|
gr.Markdown("## 1οΈβ£ Generate & Download App", elem_classes="section-header") |
|
with gr.Row(): |
|
idea_in = gr.Textbox( |
|
label="Your Robot Idea", |
|
placeholder="e.g. A friendly greeting robot.", |
|
lines=2, |
|
) |
|
with gr.Row(): |
|
gen_btn = gr.Button("Generate App & ZIP") |
|
with gr.Row(): |
|
status_out = gr.Textbox(label="Status", interactive=False) |
|
with gr.Row(): |
|
zip_out = gr.File(label="Download App ZIP") |
|
|
|
|
|
gen_btn.click( |
|
fn=deploy_callback, |
|
inputs=[idea_in], |
|
outputs=[status_out, zip_out], |
|
) |
|
|
|
|
|
gr.Markdown("## 2οΈβ£ Robot Simulator", elem_classes="section-header") |
|
cmd_in = gr.Textbox( |
|
label="Speak or Type Command", |
|
placeholder="hello or say You rock!", |
|
lines=1, |
|
) |
|
sim_btn = gr.Button("Send Command") |
|
sim_out = gr.Textbox(label="Robot Response", interactive=False, lines=4) |
|
|
|
sim_btn.click( |
|
fn=robot_behavior, |
|
inputs=[cmd_in], |
|
outputs=[sim_out], |
|
) |
|
|
|
|
|
demo.launch( |
|
server_name="0.0.0.0", |
|
server_port=int(os.environ.get("PORT", 7860)), |
|
share=False |
|
) |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|