robosage / app.py
mgbam's picture
Update app.py
798d95e verified
raw
history blame
1.93 kB
# app.py - Unified RoboSage Deployer & Simulator (CPU & Spaces-compatible)
import asyncio
import gradio as gr
from core_creator.voice_to_app import VoiceToAppCreator
from deployer.gradio_generator import robot_behavior, launch_gradio_app
async def run_pipeline(idea: str) -> str:
"""
Runs voice-to-app pipeline and returns a status message.
"""
creator = VoiceToAppCreator(idea)
assets = creator.run_pipeline()
title = assets.get("blueprint", {}).get("title", "<unknown>")
return f"βœ… Generated app: {title}"
# Synchronous wrapper for Gradio
def deploy_callback(idea: str) -> str:
return asyncio.run(run_pipeline(idea))
# Build unified Gradio interface
with gr.Blocks() as demo:
gr.Markdown("""
# πŸš€ RoboSage
Generate your custom robot app and test it live.
""")
with gr.Row():
with gr.Column():
gr.Markdown("## 1️⃣ Generate App")
user_idea = gr.Textbox(
label="Your Robot Idea",
placeholder="e.g. A friendly greeting robot."
)
deploy_btn = gr.Button("Generate App", key="deploy-app-btn")
deploy_status = gr.Textbox(label="Status", interactive=False)
deploy_btn.click(
fn=deploy_callback,
inputs=[user_idea],
outputs=[deploy_status]
)
with gr.Column():
gr.Markdown("## 2️⃣ Robot Simulator")
robot_input = gr.Textbox(
label="Command",
placeholder="hello or say You rock!"
)
robot_btn = gr.Button("Send", key="simulate-btn")
robot_output = gr.Textbox(label="Robot Response", lines=4, interactive=False)
robot_btn.click(
fn=robot_behavior,
inputs=[robot_input],
outputs=[robot_output]
)
if __name__ == "__main__":
demo.launch()