robosage / deployer /gradio_generator.py
mgbam's picture
Update deployer/gradio_generator.py
f701c15 verified
raw
history blame
2.36 kB
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
def deploy_callback(idea: str):
"""
Generates the app based on the provided idea and packages it into a ZIP file.
Returns a status message and the path to the ZIP file.
"""
creator = VoiceToAppCreator(idea)
assets = creator.run_pipeline()
title = assets.get("blueprint", {}).get("title", "<unknown>")
zip_path = package_artifacts(assets)
status_msg = f"βœ… Generated app: {title}"
return status_msg, zip_path
def robot_behavior(command: str) -> str:
"""
Simulates robot action based on a text command.
"""
return VirtualRobot().perform_action(command)
def launch_gradio_app():
"""
Builds and returns the Gradio Blocks UI for the RoboSage app.
"""
with gr.Blocks() as demo:
gr.Markdown("# πŸ€– RoboSage: Your Personal Robot App Generator")
with gr.Row():
with gr.Column():
gr.Markdown("### πŸ› οΈ Generate Your Robot App")
idea_input = gr.Textbox(
label="Enter your robot idea",
placeholder="e.g., A friendly greeting robot.",
lines=2
)
generate_button = gr.Button("Generate App")
status_output = gr.Textbox(label="Status", interactive=False)
download_output = gr.File(label="Download App ZIP")
generate_button.click(
fn=deploy_callback,
inputs=idea_input,
outputs=[status_output, download_output]
)
with gr.Column():
gr.Markdown("### πŸ€– Robot Simulator")
command_input = gr.Textbox(
label="Enter command",
placeholder="e.g., say Hello World!",
lines=1
)
send_button = gr.Button("Send Command")
response_output = gr.Textbox(label="Robot Response", interactive=False)
send_button.click(
fn=robot_behavior,
inputs=command_input,
outputs=response_output
)
return demo