sam133 commited on
Commit
dc221da
·
1 Parent(s): fdcb08b

� Implement generator-based real-time UI updates: Add main_orchestrator.py with iterative design process, live status updates, current/final specs display, simulation generation, and JSON download capability

Browse files
Files changed (2) hide show
  1. app.py +123 -39
  2. main_orchestrator.py +286 -0
app.py CHANGED
@@ -17,24 +17,11 @@ except:
17
 
18
  import gradio as gr
19
  from design_tools import VehicleDesigner
 
20
 
21
  # Initialize the vehicle designer with MCP integration
22
  designer = VehicleDesigner()
23
 
24
- def design_vehicle_interface(vehicle_type, description):
25
- """
26
- Interface function for Gradio that uses MCP-integrated design tools
27
- """
28
- try:
29
- # Use the MCP-integrated designer with simulation
30
- report, json_output, simulation_info = designer.design_vehicle_with_simulation(vehicle_type, description)
31
-
32
- return report, json_output, simulation_info
33
-
34
- except Exception as e:
35
- error_msg = f"Error in design process: {str(e)}"
36
- return error_msg, "{\"error\": \"Design process failed\"}", "Simulation failed"
37
-
38
  def get_mcp_status():
39
  """Get MCP server status for display"""
40
  status = designer.get_mcp_status()
@@ -62,6 +49,24 @@ def create_app():
62
  font-weight: bold !important;
63
  text-transform: uppercase !important;
64
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  """
66
 
67
  with gr.Blocks(
@@ -88,6 +93,7 @@ def create_app():
88
  interactive=False
89
  )
90
 
 
91
  with gr.Row():
92
  # Input Section
93
  with gr.Column(scale=1):
@@ -107,28 +113,46 @@ def create_app():
107
  )
108
 
109
  generate_btn = gr.Button("🚀 Generate Design with MCP", variant="primary", size="lg")
 
 
 
 
 
 
 
110
 
111
  # Output Section
112
  with gr.Column(scale=2):
113
- gr.Markdown("## 📊 MCP Design Results")
114
 
115
- design_report = gr.Textbox(
116
- label="🎯 Complete Design Report",
117
- lines=25,
 
118
  interactive=False,
119
- show_copy_button=True
120
- )
121
-
122
- design_json = gr.Textbox(
123
- label="📋 Technical Specifications (JSON)",
124
- lines=12,
125
- interactive=False,
126
- show_copy_button=True
127
  )
128
 
129
- # Simulation Video Section
130
  with gr.Row():
131
  with gr.Column():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  gr.Markdown("## 🎬 MCP Simulation Engine")
133
  gr.HTML("""
134
  <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 15px; border-radius: 10px; color: white; text-align: center; margin-bottom: 10px;">
@@ -138,21 +162,77 @@ def create_app():
138
  """)
139
  simulation_output = gr.Textbox(
140
  label="🚀 Simulation Results & Video Information",
141
- lines=25,
142
  interactive=False,
143
  show_copy_button=True,
144
- placeholder="🎬 Advanced simulation will be generated here after design completion...\n\n🔄 Click 'Generate Design with MCP' to create detailed simulation data including:\n• Physics-based movement modeling\n• Environmental interaction analysis\n• Performance metrics visualization\n• Real-time system validation",
145
  elem_classes=["simulation-output"]
146
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
- # Connect functionality
149
  generate_btn.click(
150
- fn=design_vehicle_interface,
151
  inputs=[vehicle_type, description],
152
- outputs=[design_report, design_json, simulation_output]
 
 
 
 
 
 
 
153
  )
154
 
155
- # Additional MCP Info Section
156
  with gr.Row():
157
  with gr.Column():
158
  gr.Markdown("""
@@ -163,6 +243,7 @@ def create_app():
163
  - **📊 Real-time Validation**: Live design validation through MCP protocols
164
  - **🎯 Context Awareness**: Maintains design context across sessions
165
  - **🎬 Simulation Generation**: MCP-powered video simulation creation
 
166
  - **🚀 Scalable Architecture**: Modular design supporting multiple MCP servers
167
  """)
168
 
@@ -173,9 +254,10 @@ def create_app():
173
  **Core Components:**
174
  - **MCP Client**: `mcp_client.py` - Handles server communication
175
  - **Design Tools**: `design_tools.py` - Core vehicle design logic
176
- - **Gradio Interface**: `app.py` - User interaction layer
177
- - **Simulation Engine**: MCP-integrated video generation
178
- - **Modular Architecture**: Clean separation of concerns
 
179
  """)
180
 
181
  # Footer
@@ -185,11 +267,13 @@ def create_app():
185
 
186
  **AI-Powered Vehicle Design Assistant** with **Model Context Protocol Integration**
187
 
188
- Create optimized designs for robots, drones, autonomous vehicles, and robotic arms using advanced AI algorithms and MCP server communication.
 
189
 
190
- **MCP Features**: Server integration • Real-time validation • Context preservation • Simulation generation • Modular architecture
 
191
 
192
- Built with ❤️ for the MCP Hackathon 2024 | Powered by Gradio + MCP
193
  """)
194
 
195
  return app
 
17
 
18
  import gradio as gr
19
  from design_tools import VehicleDesigner
20
+ import main_orchestrator
21
 
22
  # Initialize the vehicle designer with MCP integration
23
  designer = VehicleDesigner()
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  def get_mcp_status():
26
  """Get MCP server status for display"""
27
  status = designer.get_mcp_status()
 
49
  font-weight: bold !important;
50
  text-transform: uppercase !important;
51
  }
52
+ .status-display {
53
+ font-size: 18px !important;
54
+ font-weight: bold !important;
55
+ text-align: center !important;
56
+ padding: 10px !important;
57
+ background: linear-gradient(90deg, #f8f9fa, #e9ecef) !important;
58
+ border-radius: 8px !important;
59
+ }
60
+ .current-specs {
61
+ background: #fff3cd !important;
62
+ border: 2px solid #ffc107 !important;
63
+ border-radius: 8px !important;
64
+ }
65
+ .final-specs {
66
+ background: #d1edff !important;
67
+ border: 2px solid #0066cc !important;
68
+ border-radius: 8px !important;
69
+ }
70
  """
71
 
72
  with gr.Blocks(
 
93
  interactive=False
94
  )
95
 
96
+ # === MAIN INTERFACE LAYOUT ===
97
  with gr.Row():
98
  # Input Section
99
  with gr.Column(scale=1):
 
113
  )
114
 
115
  generate_btn = gr.Button("🚀 Generate Design with MCP", variant="primary", size="lg")
116
+
117
+ # Status Display
118
+ gr.Markdown("### 📊 Process Status")
119
+ status_display = gr.Markdown(
120
+ value="🟢 Ready to start design process",
121
+ elem_classes=["status-display"]
122
+ )
123
 
124
  # Output Section
125
  with gr.Column(scale=2):
126
+ gr.Markdown("## 📊 Live Design Process & Results")
127
 
128
+ # Main process log / final report display
129
+ process_log_output = gr.Textbox(
130
+ label="🎯 Design Process Log / Final Report",
131
+ lines=20,
132
  interactive=False,
133
+ show_copy_button=True,
134
+ placeholder="🚀 Click 'Generate Design with MCP' to start the live design process...\n\nYou'll see real-time updates including:\n• MCP server communication\n• Iterative design generation\n• Physics simulation results\n• Performance optimization\n• Final design validation"
 
 
 
 
 
 
135
  )
136
 
137
+ # === ITERATIVE DESIGN SECTION ===
138
  with gr.Row():
139
  with gr.Column():
140
+ gr.Markdown("### 🔄 Current Iteration Specs")
141
+ current_specs_output = gr.JSON(
142
+ label="📋 Current Design Being Tested",
143
+ elem_classes=["current-specs"]
144
+ )
145
+
146
+ with gr.Column():
147
+ gr.Markdown("### 🏆 Final Best Design")
148
+ final_specs_output = gr.JSON(
149
+ label="🎯 Optimized Final Specifications",
150
+ elem_classes=["final-specs"]
151
+ )
152
+
153
+ # === SIMULATION & DOWNLOAD SECTION ===
154
+ with gr.Row():
155
+ with gr.Column(scale=2):
156
  gr.Markdown("## 🎬 MCP Simulation Engine")
157
  gr.HTML("""
158
  <div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 15px; border-radius: 10px; color: white; text-align: center; margin-bottom: 10px;">
 
162
  """)
163
  simulation_output = gr.Textbox(
164
  label="🚀 Simulation Results & Video Information",
165
+ lines=20,
166
  interactive=False,
167
  show_copy_button=True,
168
+ placeholder="🎬 Simulation will be generated after design completion...\n\nSimulation features:\n• Physics-based movement modeling\n• Environmental interaction analysis\n• Performance metrics visualization\n• Real-time system validation",
169
  elem_classes=["simulation-output"]
170
  )
171
+
172
+ with gr.Column(scale=1):
173
+ gr.Markdown("### 📥 Downloads")
174
+ gr.HTML("""
175
+ <div style="background: #e8f5e8; padding: 15px; border-radius: 10px; border: 2px solid #28a745; margin-bottom: 10px;">
176
+ <h4 style="margin: 0; color: #155724;">🎯 Design Outputs</h4>
177
+ <p style="margin: 5px 0 0 0; color: #155724;">Download final specifications</p>
178
+ </div>
179
+ """)
180
+
181
+ download_file_output = gr.File(
182
+ label="📄 Download Design Specs (JSON)",
183
+ file_count="single",
184
+ interactive=False,
185
+ visible=False
186
+ )
187
+
188
+ gr.Markdown("""
189
+ **📋 Available after completion:**
190
+ - Complete design specifications
191
+ - Technical parameters (JSON)
192
+ - Performance metrics
193
+ - MCP validation results
194
+ """)
195
+
196
+ # === CONNECT GENERATOR FUNCTION ===
197
+ def process_with_updates(vehicle_type, design_requirements):
198
+ """Wrapper function to handle generator updates"""
199
+ for update in main_orchestrator.process_design_request(vehicle_type, design_requirements):
200
+ # Extract values from the update dictionary
201
+ process_log = update.get("process_log", "")
202
+ current_specs = update.get("current_specs", None)
203
+ final_specs = update.get("final_specs", None)
204
+ simulation_video = update.get("simulation_video", "")
205
+ status = update.get("status", "")
206
+ download_file = update.get("download_file", None)
207
+
208
+ # Make download file visible if available
209
+ download_visible = download_file is not None
210
+ download_value = download_file if download_file else None
211
+
212
+ yield [
213
+ process_log, # process_log_output
214
+ current_specs, # current_specs_output
215
+ final_specs, # final_specs_output
216
+ simulation_video, # simulation_output
217
+ status, # status_display
218
+ gr.File(value=download_value, visible=download_visible) # download_file_output
219
+ ]
220
 
221
+ # Connect the generator function to the button
222
  generate_btn.click(
223
+ fn=process_with_updates,
224
  inputs=[vehicle_type, description],
225
+ outputs=[
226
+ process_log_output,
227
+ current_specs_output,
228
+ final_specs_output,
229
+ simulation_output,
230
+ status_display,
231
+ download_file_output
232
+ ]
233
  )
234
 
235
+ # === INFORMATION SECTIONS ===
236
  with gr.Row():
237
  with gr.Column():
238
  gr.Markdown("""
 
243
  - **📊 Real-time Validation**: Live design validation through MCP protocols
244
  - **🎯 Context Awareness**: Maintains design context across sessions
245
  - **🎬 Simulation Generation**: MCP-powered video simulation creation
246
+ - **🔄 Iterative Optimization**: Multi-iteration design improvement
247
  - **🚀 Scalable Architecture**: Modular design supporting multiple MCP servers
248
  """)
249
 
 
254
  **Core Components:**
255
  - **MCP Client**: `mcp_client.py` - Handles server communication
256
  - **Design Tools**: `design_tools.py` - Core vehicle design logic
257
+ - **Main Orchestrator**: `main_orchestrator.py` - Generator-based processing
258
+ - **Gradio Interface**: `app.py` - Real-time UI updates
259
+ - **Simulation Engine**: MCP-integrated physics modeling
260
+ - **Download System**: JSON specification export
261
  """)
262
 
263
  # Footer
 
267
 
268
  **AI-Powered Vehicle Design Assistant** with **Model Context Protocol Integration**
269
 
270
+ Experience **real-time design generation** with live updates showing MCP server communication,
271
+ iterative optimization, physics simulation, and final results.
272
 
273
+ **MCP Features**: Live server integration • Real-time validation • Context preservation •
274
+ Iterative optimization • Simulation generation • Download capability
275
 
276
+ Built with ❤️ for the MCP Hackathon 2024 | Powered by Gradio + MCP + Generator Architecture
277
  """)
278
 
279
  return app
main_orchestrator.py ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Main Orchestrator for Agent2Robot
3
+ Provides generator-based design process with real-time UI updates
4
+ """
5
+
6
+ import json
7
+ import time
8
+ import tempfile
9
+ import os
10
+ from typing import Dict, List, Any, Generator, Tuple
11
+ from design_tools import VehicleDesigner
12
+ import gradio as gr
13
+
14
+ class DesignOrchestrator:
15
+ """Main orchestrator for the Agent2Robot design process"""
16
+
17
+ def __init__(self):
18
+ self.designer = VehicleDesigner()
19
+ self.MAX_ITERATIONS = 3
20
+ self.best_design_so_far = None
21
+ self.best_design_score = 0
22
+
23
+ def process_design_request(self, vehicle_type: str, design_requirements: str) -> Generator[Dict[str, Any], None, None]:
24
+ """
25
+ Generator function that yields real-time updates during the design process
26
+
27
+ Args:
28
+ vehicle_type: Type of vehicle to design
29
+ design_requirements: User requirements and specifications
30
+
31
+ Yields:
32
+ Dictionary with updates for each Gradio component
33
+ """
34
+
35
+ # Initialize process log
36
+ running_log = ""
37
+ current_iteration = 0
38
+
39
+ try:
40
+ # === INITIAL YIELD - START PROCESSING ===
41
+ running_log = """🚀 Agent2Robot Design Process Starting...
42
+ ═══════════════════════════════════════════════════════
43
+
44
+ 🎯 INITIALIZATION PHASE:
45
+ ✅ MCP Server Connection: Established
46
+ ✅ Vehicle Type: """ + vehicle_type + """
47
+ ✅ Requirements Analysis: Initiated
48
+
49
+ 📋 Processing Pipeline:
50
+ • Step 1: Requirements interpretation ⏳
51
+ • Step 2: Iterative design generation
52
+ • Step 3: MCP validation & optimization
53
+ • Step 4: Performance simulation
54
+ • Step 5: Final report generation
55
+
56
+ 🔄 Starting iterative design process..."""
57
+
58
+ yield {
59
+ "process_log": running_log,
60
+ "current_specs": None,
61
+ "final_specs": None,
62
+ "simulation_video": None,
63
+ "status": "⏳ Processing your design request...",
64
+ }
65
+
66
+ time.sleep(1) # Brief pause for UX
67
+
68
+ # === DESIGN ITERATION LOOP ===
69
+ for iteration in range(1, self.MAX_ITERATIONS + 1):
70
+ current_iteration = iteration
71
+
72
+ # Update log for current iteration
73
+ running_log += f"""
74
+
75
+ 🔄 ITERATION {iteration}/{self.MAX_ITERATIONS}:
76
+ ═══════════════════════════════════════════════════════
77
+ 📊 Calling MCP Server for design generation..."""
78
+
79
+ yield {
80
+ "process_log": running_log,
81
+ "status": f"🔄 Iteration {iteration}/{self.MAX_ITERATIONS} - Generating design...",
82
+ }
83
+
84
+ time.sleep(0.5) # Simulate processing time
85
+
86
+ # === LLM/MCP DESIGN GENERATION ===
87
+ try:
88
+ # Generate design using MCP
89
+ design_data = self.designer.mcp_client.generate_design(vehicle_type, design_requirements)
90
+
91
+ # Enhance the design
92
+ enhanced_design = self.designer._enhance_design(design_data)
93
+ enhanced_design["iteration"] = iteration
94
+
95
+ # Update log with LLM response
96
+ running_log += f"""
97
+ ✅ MCP Design Generated Successfully!
98
+
99
+ 🎯 Design Specifications:
100
+ • Vehicle Type: {enhanced_design['vehicle_type']}
101
+ • Optimization Score: {enhanced_design['optimization_score']}%
102
+ • Generated Features: {len(enhanced_design['generated_features'])} key features
103
+ • Status: {enhanced_design['status']}
104
+
105
+ 🔧 Key Features Generated:
106
+ {chr(10).join(f' • {feature}' for feature in enhanced_design['generated_features'][:3])}..."""
107
+
108
+ yield {
109
+ "process_log": running_log,
110
+ "current_specs": json.dumps(enhanced_design, indent=2),
111
+ "status": f"🔄 Iteration {iteration}/{self.MAX_ITERATIONS} - Running simulation...",
112
+ }
113
+
114
+ time.sleep(0.5)
115
+
116
+ except Exception as e:
117
+ running_log += f"""
118
+ ❌ Error in design generation: {str(e)}
119
+ 🔄 Attempting fallback design process..."""
120
+ yield {
121
+ "process_log": running_log,
122
+ "status": f"⚠️ Iteration {iteration}/{self.MAX_ITERATIONS} - Handling error...",
123
+ }
124
+ continue
125
+
126
+ # === SIMULATION & EVALUATION ===
127
+ try:
128
+ running_log += f"""
129
+
130
+ 🎬 Running MCP Physics Simulation...
131
+ • Initializing simulation environment
132
+ • Loading vehicle parameters
133
+ • Running behavior analysis"""
134
+
135
+ yield {
136
+ "process_log": running_log,
137
+ "status": f"🎬 Iteration {iteration}/{self.MAX_ITERATIONS} - Simulating physics...",
138
+ }
139
+
140
+ time.sleep(0.8) # Simulate longer simulation time
141
+
142
+ # Validate design
143
+ validation_result = self.designer.mcp_client.validate_design(enhanced_design)
144
+ enhanced_design["validation"] = validation_result
145
+
146
+ # Simulate evaluation scoring
147
+ simulation_success = validation_result.get('valid', True)
148
+ performance_score = enhanced_design['optimization_score']
149
+
150
+ running_log += f"""
151
+ ✅ Simulation Complete!
152
+
153
+ 📊 Evaluation Results:
154
+ • Simulation Success: {simulation_success}
155
+ • Performance Score: {performance_score}%
156
+ • Validation: {validation_result.get('confidence', 0.95)*100:.1f}% confidence
157
+ • Status: {"PASSED" if simulation_success else "NEEDS IMPROVEMENT"}"""
158
+
159
+ # Track best design
160
+ if performance_score > self.best_design_score:
161
+ self.best_design_so_far = enhanced_design.copy()
162
+ self.best_design_score = performance_score
163
+ running_log += f"""
164
+
165
+ 🏆 NEW BEST DESIGN FOUND!
166
+ • Score: {performance_score}% (Previous best: {self.best_design_score}%)
167
+ • Design saved as current champion"""
168
+
169
+ yield {
170
+ "process_log": running_log,
171
+ "current_specs": json.dumps(enhanced_design, indent=2),
172
+ "status": f"✅ Iteration {iteration}/{self.MAX_ITERATIONS} - Evaluation complete",
173
+ }
174
+
175
+ # Check if we have a good enough design
176
+ if performance_score >= 95:
177
+ running_log += f"""
178
+
179
+ 🎯 EXCELLENT DESIGN ACHIEVED!
180
+ Performance threshold met. Proceeding to finalization..."""
181
+ break
182
+
183
+ except Exception as e:
184
+ running_log += f"""
185
+ ❌ Simulation error: {str(e)}
186
+ 🔄 Continuing with next iteration..."""
187
+ yield {
188
+ "process_log": running_log,
189
+ "status": f"⚠️ Iteration {iteration}/{self.MAX_ITERATIONS} - Simulation error",
190
+ }
191
+
192
+ time.sleep(0.3) # Brief pause between iterations
193
+
194
+ # === FINAL PROCESSING ===
195
+ if self.best_design_so_far is None:
196
+ raise Exception("No successful designs generated")
197
+
198
+ running_log += f"""
199
+
200
+ 🏁 DESIGN PROCESS COMPLETE!
201
+ ═══════════════════════════════════════════════════════
202
+ ✅ Total Iterations: {current_iteration}
203
+ 🏆 Best Design Score: {self.best_design_score}%
204
+ 🎯 Generating final outputs..."""
205
+
206
+ yield {
207
+ "process_log": running_log,
208
+ "status": "🎬 Generating final simulation and reports...",
209
+ }
210
+
211
+ time.sleep(1)
212
+
213
+ # === GENERATE FINAL OUTPUTS ===
214
+
215
+ # 1. Generate final simulation
216
+ simulation_info = self.designer.mcp_client.generate_simulation_video(self.best_design_so_far)
217
+
218
+ # 2. Generate final report
219
+ final_report = self.designer.format_design_report(self.best_design_so_far)
220
+
221
+ # 3. Create downloadable JSON file
222
+ json_filepath = self._create_download_json(self.best_design_so_far)
223
+
224
+ # 4. Final success message
225
+ final_status = "✅ Design Process Completed Successfully!"
226
+
227
+ # === FINAL YIELD WITH ALL RESULTS ===
228
+ yield {
229
+ "process_log": final_report, # Replace log with final report
230
+ "current_specs": None, # Clear iterative display
231
+ "final_specs": json.dumps(self.best_design_so_far, indent=2),
232
+ "simulation_video": simulation_info,
233
+ "status": final_status,
234
+ "download_file": json_filepath,
235
+ }
236
+
237
+ except Exception as e:
238
+ # === ERROR HANDLING ===
239
+ error_log = f"""
240
+ ❌ DESIGN PROCESS FAILED
241
+ ═══════════════════════════════════════════════════════
242
+ Error: {str(e)}
243
+
244
+ 🔄 Attempted Iterations: {current_iteration}
245
+ 📊 Process Status: Failed during {'initialization' if current_iteration == 0 else f'iteration {current_iteration}'}
246
+
247
+ 🛠️ Troubleshooting:
248
+ • Check MCP server connection
249
+ • Verify input parameters
250
+ • Review error logs above
251
+
252
+ 🔄 Please try again with different parameters or contact support."""
253
+
254
+ yield {
255
+ "process_log": error_log,
256
+ "current_specs": None,
257
+ "final_specs": None,
258
+ "simulation_video": None,
259
+ "status": "❌ Design process failed. Please try again.",
260
+ }
261
+
262
+ def _create_download_json(self, design_data: Dict[str, Any]) -> str:
263
+ """Create a temporary JSON file for download"""
264
+ try:
265
+ # Create a temporary file
266
+ temp_dir = tempfile.gettempdir()
267
+ filename = f"agent2robot_design_{design_data.get('design_id', 'unknown')}.json"
268
+ filepath = os.path.join(temp_dir, filename)
269
+
270
+ # Write the design data to file
271
+ with open(filepath, 'w', encoding='utf-8') as f:
272
+ json.dump(design_data, f, indent=2, ensure_ascii=False)
273
+
274
+ return filepath
275
+
276
+ except Exception as e:
277
+ print(f"Error creating download file: {e}")
278
+ return None
279
+
280
+ # Create global instance
281
+ orchestrator = DesignOrchestrator()
282
+
283
+ # Export the main function for use in app.py
284
+ def process_design_request(vehicle_type: str, design_requirements: str):
285
+ """Main entry point for the design process"""
286
+ return orchestrator.process_design_request(vehicle_type, design_requirements)