File size: 2,215 Bytes
67f9d7b
660b656
43d80bd
f69fdac
43d80bd
 
 
 
 
4e2e4a9
67f9d7b
43d80bd
 
f69fdac
43d80bd
 
 
 
 
 
 
 
 
 
 
 
f69fdac
43d80bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67f9d7b
43d80bd
38c7720
 
 
 
 
f4f0212
0180e60
67f9d7b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import os
import gradio as gr
from deployer.gradio_generator import deploy_callback, robot_behavior

def main():
    # simple CSS to center the UI and style sections
    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.")

        # ─── SECTION 1: Generate & Download App ─────────────────────────────────────────
        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")

        # hook up
        gen_btn.click(
            fn=deploy_callback,
            inputs=[idea_in],
            outputs=[status_out, zip_out],
        )

        # ─── SECTION 2: Robot Simulator ────────────────────────────────────────────────
        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],
        )

        # launch parameters
        demo.launch(
            server_name="0.0.0.0",
            server_port=int(os.environ.get("PORT", 7860)),
            share=False
        )

if __name__ == "__main__":
    main()