Download deployer/gradio_generator.py from mgbam/robosage: direct link, hf CLI and curl.
- Browser
- Download file 3.29 kB
-
https://huggingface.co/spaces/mgbam/robosage/resolve/1b36f733c9698a310e57c4e089bd8b90910049d0/deployer/gradio_generator.py
- Command line
-
hf download hf://spaces/mgbam/robosage@1b36f733c9698a310e57c4e089bd8b90910049d0/deployer/gradio_generator.py
-
curl -L -o gradio_generator.py https://huggingface.co/spaces/mgbam/robosage/resolve/1b36f733c9698a310e57c4e089bd8b90910049d0/deployer/gradio_generator.py
3.29 kB
| # deployer/gradio_generator.py | |
| import asyncio | |
| import gradio as gr | |
| from core_creator.voice_to_app import VoiceToAppCreator | |
| from deployer.simulator_interface import VirtualRobot | |
| from deployer.revenue_tracker import package_artifacts | |
| async def _run_pipeline(idea: str) -> str: | |
| """ | |
| Asynchronously run the voiceβapp pipeline and return a status message. | |
| """ | |
| creator = VoiceToAppCreator(idea) | |
| assets = creator.run_pipeline() | |
| title = assets.get("blueprint", {}).get("title", "<unknown>") | |
| return f"β Generated app: {title}" | |
| def deploy_callback(idea: str) -> str: | |
| """ | |
| Synchronous wrapper for Gradio: generate the app. | |
| """ | |
| return asyncio.run(_run_pipeline(idea)) | |
| def robot_behavior(user_input: str) -> str: | |
| """ | |
| Simulate robot action based on a user command. | |
| """ | |
| return VirtualRobot().perform_action(user_input) | |
| def download_callback() -> str: | |
| """ | |
| Package all generated app artifacts into a ZIP and return its file path. | |
| """ | |
| zip_path = package_artifacts() | |
| return zip_path | |
| def launch_gradio_app() -> gr.Blocks: | |
| """ | |
| Build and return the Gradio interface. | |
| """ | |
| demo = gr.Blocks() | |
| with demo: | |
| gr.Markdown( | |
| "## π RoboSage \n" | |
| "Generate your custom robot app and test it live." | |
| ) | |
| with gr.Row(): | |
| # ββββββββββββββββββββββββββββ | |
| # 1οΈβ£ Generate App + Download ZIP | |
| # ββββββββββββββββββββββββββββ | |
| with gr.Column(scale=1): | |
| gr.Markdown("### 1οΈβ£ Generate App") | |
| idea_input = gr.Textbox( | |
| label="Your Robot Idea", | |
| placeholder="e.g. A friendly greeting robot." | |
| ) | |
| gen_btn = gr.Button("Generate App") | |
| status_out = gr.Textbox(label="Status", interactive=False) | |
| gen_btn.click( | |
| fn=deploy_callback, | |
| inputs=[idea_input], | |
| outputs=[status_out] | |
| ) | |
| download_btn = gr.Button("π¦ Download App ZIP") | |
| zip_out = gr.File(label="Your App ZIP") | |
| download_btn.click( | |
| fn=download_callback, | |
| outputs=[zip_out] | |
| ) | |
| # ββββββββββββββββββββββββββββ | |
| # 2οΈβ£ Robot Simulator | |
| # ββββββββββββββββββββββββββββ | |
| with gr.Column(scale=1): | |
| gr.Markdown("### 2οΈβ£ Robot Simulator") | |
| cmd_input = gr.Textbox( | |
| label="Speak or Type Command", | |
| placeholder="hello or say You rock!" | |
| ) | |
| send_btn = gr.Button("Send") | |
| resp_out = gr.Textbox(label="Robot Response", lines=4, interactive=False) | |
| send_btn.click( | |
| fn=robot_behavior, | |
| inputs=[cmd_input], | |
| outputs=[resp_out] | |
| ) | |
| return demo | |
| if __name__ == "__main__": | |
| launch_gradio_app().launch() | |