|
|
|
|
|
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) |
|
|
|
|
|
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() |
|
|