File size: 2,707 Bytes
750f440 d078b7e 181f321 88f811c 1b36f73 88f811c 51b18cb d1faaf8 c668a21 70154bd 1b36f73 70154bd e8ee41e 750f440 c668a21 750f440 51b18cb 750f440 181f321 e8ee41e 1b36f73 c668a21 1b36f73 e8ee41e 50d96bd 750f440 c668a21 70154bd c668a21 750f440 51b18cb 70154bd c668a21 e8ee41e 51b18cb 1b36f73 51b18cb 750f440 e8ee41e 70154bd 750f440 70154bd 750f440 1b36f73 750f440 1b36f73 c668a21 e8ee41e 750f440 e8ee41e 70154bd 750f440 1b36f73 750f440 70154bd 750f440 70154bd 181f321 51b18cb c668a21 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
import os
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 generate_app_async(idea: str):
"""
Run the voice-to-app pipeline asynchronously and return a tuple of (status_message, zip_path).
"""
creator = VoiceToAppCreator(idea)
assets = creator.run_pipeline()
title = assets.get("blueprint", {}).get("title", "<unknown>")
zip_path = package_artifacts(assets)
status = f"β
Generated app: {title}"
return status, zip_path
def deploy_callback(idea: str):
"""
Synchronous wrapper for Gradio: generates the app and packages it into a ZIP.
Returns (status_message, zip_path).
"""
return asyncio.run(generate_app_async(idea))
def robot_behavior(command: str) -> str:
"""
Simulate robot behavior based on a text command.
"""
return VirtualRobot().perform_action(command)
def main():
"""
Build and launch the Gradio UI for RoboSage.
"""
with gr.Blocks() as demo:
gr.Markdown("# π RoboSage\nGenerate your custom robot app and test it live.")
with gr.Row():
# Generate & Download App Section
with gr.Column():
gr.Markdown("## 1οΈβ£ Generate & Download App")
idea_input = gr.Textbox(
label="Your Robot Idea",
placeholder="e.g. A friendly greeting robot.",
lines=2
)
gen_btn = gr.Button("Generate App")
status_out = gr.Textbox(label="Status", interactive=False)
zip_out = gr.File(label="Download App ZIP")
gen_btn.click(
fn=deploy_callback,
inputs=[idea_input],
outputs=[status_out, zip_out]
)
# Robot Simulator Section
with gr.Column():
gr.Markdown("## π€ Robot Simulator")
cmd_input = gr.Textbox(
label="Command",
placeholder="hello or say You rock!",
lines=1
)
sim_btn = gr.Button("Send")
sim_out = gr.Textbox(label="Robot Response", lines=4, interactive=False)
sim_btn.click(
fn=robot_behavior,
inputs=[cmd_input],
outputs=[sim_out]
)
demo.launch(
server_name="0.0.0.0",
server_port=int(os.environ.get("PORT", 7860)),
share=False
)
if __name__ == "__main__":
main()
|