Update deployer/deployer.py
Browse files- deployer/deployer.py +40 -23
deployer/deployer.py
CHANGED
@@ -1,26 +1,43 @@
|
|
1 |
-
# deployer.py -
|
2 |
|
|
|
|
|
|
|
3 |
from deployer.gradio_generator import launch_gradio_app
|
4 |
-
import
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
1 |
+
# deployer.py - Orchestrates full app deployment: from code to interactive app
|
2 |
|
3 |
+
import os
|
4 |
+
import time
|
5 |
+
from core_creator.voice_to_app import VoiceToAppCreator
|
6 |
from deployer.gradio_generator import launch_gradio_app
|
7 |
+
from gradio import Blocks
|
8 |
+
|
9 |
+
# Optional: create a folder to store generated apps or logs
|
10 |
+
GENERATED_DIR = "generated_apps"
|
11 |
+
os.makedirs(GENERATED_DIR, exist_ok=True)
|
12 |
+
|
13 |
+
def deploy_robot_app(user_idea: str) -> dict:
|
14 |
+
print("[π] Starting deployment for user idea...")
|
15 |
+
|
16 |
+
# Step 1: Generate all components
|
17 |
+
creator = VoiceToAppCreator(user_idea)
|
18 |
+
app_assets = creator.run_pipeline()
|
19 |
+
|
20 |
+
# Step 2: Save the generated code (optional archival)
|
21 |
+
code_path = os.path.join(GENERATED_DIR, f"{app_assets['intent']}_robot_app.py")
|
22 |
+
with open(code_path, "w") as f:
|
23 |
+
f.write(app_assets["code"])
|
24 |
+
print(f"[π¦] Code saved at: {code_path}")
|
25 |
+
|
26 |
+
# Step 3: Launch app in memory
|
27 |
+
app_ui: Blocks = launch_gradio_app(
|
28 |
+
title=app_assets["blueprint"]["title"],
|
29 |
+
description=app_assets["blueprint"]["description"]
|
30 |
+
)
|
31 |
+
|
32 |
+
print("[β
] Deployment ready! Launching app...")
|
33 |
+
app_ui.launch(share=True)
|
34 |
+
return {
|
35 |
+
"status": "success",
|
36 |
+
"intent": app_assets['intent'],
|
37 |
+
"code_file": code_path
|
38 |
}
|
39 |
+
|
40 |
+
# Example usage
|
41 |
+
if __name__ == "__main__":
|
42 |
+
idea = "Build a robot that compliments people when they smile at it."
|
43 |
+
deploy_robot_app(idea)
|