mgbam commited on
Commit
6ce167c
Β·
verified Β·
1 Parent(s): 4c185ee

Update deployer/deployer.py

Browse files
Files changed (1) hide show
  1. deployer/deployer.py +40 -23
deployer/deployer.py CHANGED
@@ -1,26 +1,43 @@
1
- # deployer.py - Launch pipeline for RoboSage-generated apps
2
 
 
 
 
3
  from deployer.gradio_generator import launch_gradio_app
4
- import datetime
5
-
6
- class AppDeployer:
7
- def __init__(self, blueprint):
8
- self.title = blueprint.get("title", "Robo App")
9
- self.description = blueprint.get("description", "A custom robot experience")
10
- self.timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
11
- self.launch_id = f"{self.title.replace(' ', '_')}_{self.timestamp}"
12
-
13
- def deploy(self):
14
- print(f"[πŸš€] Deploying: {self.title} ({self.launch_id})")
15
- app = launch_gradio_app(self.title, self.description)
16
- app.launch(share=True)
17
- print("[βœ…] App launched on Hugging Face!")
18
-
19
- # Example
20
- if __name__ == "__main__":
21
- test_blueprint = {
22
- "title": "GreeterBot",
23
- "description": "Waves hello and greets users at your shop entrance."
 
 
 
 
 
 
 
 
 
 
 
24
  }
25
- deployer = AppDeployer(test_blueprint)
26
- deployer.deploy()
 
 
 
 
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)