File size: 1,403 Bytes
6ce167c
e4bc283
6ce167c
 
 
e4bc283
6ce167c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4bc283
6ce167c
 
 
 
 
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
# deployer.py - Orchestrates full app deployment: from code to interactive app

import os
import time
from core_creator.voice_to_app import VoiceToAppCreator
from deployer.gradio_generator import launch_gradio_app
from gradio import Blocks

# Optional: create a folder to store generated apps or logs
GENERATED_DIR = "generated_apps"
os.makedirs(GENERATED_DIR, exist_ok=True)

def deploy_robot_app(user_idea: str) -> dict:
    print("[πŸš€] Starting deployment for user idea...")

    # Step 1: Generate all components
    creator = VoiceToAppCreator(user_idea)
    app_assets = creator.run_pipeline()

    # Step 2: Save the generated code (optional archival)
    code_path = os.path.join(GENERATED_DIR, f"{app_assets['intent']}_robot_app.py")
    with open(code_path, "w") as f:
        f.write(app_assets["code"])
    print(f"[πŸ“¦] Code saved at: {code_path}")

    # Step 3: Launch app in memory
    app_ui: Blocks = launch_gradio_app(
        title=app_assets["blueprint"]["title"],
        description=app_assets["blueprint"]["description"]
    )

    print("[βœ…] Deployment ready! Launching app...")
    app_ui.launch(share=True)
    return {
        "status": "success",
        "intent": app_assets['intent'],
        "code_file": code_path
    }

# Example usage
if __name__ == "__main__":
    idea = "Build a robot that compliments people when they smile at it."
    deploy_robot_app(idea)