robosage / app.py
mgbam's picture
Update app.py
660b656 verified
raw
history blame
1.91 kB
# app.py - Unified RoboSage Deployer & Simulator (CPU & Spaces-compatible)
import os
import asyncio
import gradio as gr
from core_creator.voice_to_app import VoiceToAppCreator
from deployer.simulator_interface import VirtualRobot
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}"
def deploy_callback(idea: str) -> str:
"""Sync wrapper for Gradio."""
return asyncio.run(run_pipeline(idea))
def robot_behavior(user_input: str) -> str:
"""Simulate robot action based on user text."""
return VirtualRobot().perform_action(user_input)
# Build unified Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# πŸš€ RoboSage\nGenerate your custom robot app and test it live.")
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")
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="Speak or Type Command",
placeholder="hello or say You rock!"
)
robot_btn = gr.Button("Send", key="simulate-btn")
robot_output = gr.Textbox(label="Robot Response", lines=4)
robot_btn.click(
fn=robot_behavior,
inputs=[robot_input],
outputs=[robot_output]
)
if __name__ == "__main__":
demo.launch()