mgbam commited on
Commit
0103479
Β·
verified Β·
1 Parent(s): 1d5d1d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -39
app.py CHANGED
@@ -1,46 +1,49 @@
 
 
 
 
1
  import gradio as gr
2
  import asyncio
3
- from core_creator.voice_to_app import VoiceToAppCreator
4
- from deployer.gradio_generator import launch_gradio_app
5
- import os
6
- import logging
7
 
8
- # Configure environment
9
- os.environ["GEMINI_API_KEY"] = os.getenv("GEMINI_API_KEY", "")
10
- os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_API_KEY", "")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- async def process_idea(idea: str):
13
- """End-to-end idea processing pipeline"""
14
- try:
15
- creator = VoiceToAppCreator(idea)
16
- app_assets = creator.run_pipeline()
17
-
18
- title = app_assets["blueprint"].get("title", "RoboApp")
19
- description = app_assets["blueprint"].get("description", "AI-powered robot app.")
20
-
21
- interface = launch_gradio_app(title=title, description=description)
22
- return f"βœ… {title} launched successfully!"
23
- except Exception as e:
24
- logging.error(f"Processing failed: {e}")
25
- return f"❌ Error: {str(e)}"
26
 
27
- def create_launcher():
28
- """Main launcher interface"""
29
- with gr.Blocks() as launcher:
30
- gr.Markdown("# πŸš€ RoboSage Creator")
31
-
32
- idea_input = gr.Textbox(label="Your Idea", lines=3)
33
- status_output = gr.Textbox(label="Status", interactive=False)
34
-
35
- gr.Button("Create").click(
36
- fn=lambda idea: asyncio.run(process_idea(idea)),
37
- inputs=idea_input,
38
- outputs=status_output
39
- )
40
-
41
- return launcher
42
 
 
43
  if __name__ == "__main__":
44
- logging.basicConfig(level=logging.INFO)
45
- app = create_launcher()
46
- app.launch(server_name="0.0.0.0", server_port=7860)
 
1
+ # app.py - Unified RoboSage Deployer & Robot Simulator (CPU & Spaces-compatible)
2
+ import os
3
+ from core_creator.voice_to_app import VoiceToAppCreator
4
+ from deployer.simulator_interface import VirtualRobot
5
  import gradio as gr
6
  import asyncio
 
 
 
 
7
 
8
+ # Pipeline runner: generates app blueprint and code
9
+ async def run_pipeline(idea: str) -> str:
10
+ """
11
+ Runs the voice-to-app pipeline and returns a status message.
12
+ """
13
+ creator = VoiceToAppCreator(idea)
14
+ assets = creator.run_pipeline()
15
+ title = assets.get("blueprint", {}).get("title", "<unknown>")
16
+ return f"βœ… Generated app: {title}"
17
+
18
+ # Synchronous wrapper for Gradio use
19
+ def deploy_callback(idea: str) -> str:
20
+ return asyncio.run(run_pipeline(idea))
21
+
22
+ # Robot simulator callback
23
+ def robot_behavior(user_input: str) -> str:
24
+ """
25
+ Simulate robot action based on user text.
26
+ """
27
+ return VirtualRobot().perform_action(user_input)
28
 
29
+ # Build unified Gradio interface
30
+ with gr.Blocks() as demo:
31
+ gr.Markdown("""# πŸš€ RoboSage
32
+ Generate your custom robot app and test it live in one interface.""")
33
+ with gr.Column():
34
+ gr.Markdown("## 1️⃣ Generate App")
35
+ user_idea = gr.Textbox(label="Your Robot Idea", placeholder="e.g. A friendly greeting robot.")
36
+ deploy_btn = gr.Button("Generate App", key="deploy-app-btn")
37
+ deploy_status = gr.Textbox(label="Status")
38
+ deploy_btn.click(fn=deploy_callback, inputs=[user_idea], outputs=[deploy_status])
 
 
 
 
39
 
40
+ with gr.Column():
41
+ gr.Markdown("## 2️⃣ Robot Simulator")
42
+ robot_input = gr.Textbox(label="Speak or Type Command", placeholder="hello or say You rock!")
43
+ robot_btn = gr.Button("Send", key="simulate-btn")
44
+ robot_output = gr.Textbox(label="Robot Response", lines=4)
45
+ robot_btn.click(fn=robot_behavior, inputs=[robot_input], outputs=[robot_output])
 
 
 
 
 
 
 
 
 
46
 
47
+ # Launch the complete app
48
  if __name__ == "__main__":
49
+ demo.launch()