Spaces:
No application file
No application file
sam133
commited on
Commit
·
ca1c22f
1
Parent(s):
9f19a03
� PHASE 1: Deploy minimal Gradio app for baseline testing
Browse files✅ Created minimal app with only basic components:
- Simple gr.Textbox input/output
- Basic gr.Button with simple function
- No complex components or backend imports
✅ Minimal requirements.txt with only Gradio
✅ Backup of original app saved as app_backup.py
Goal: Test if basic Gradio functionality works without TypeError
- app.py +31 -450
- app_backup.py +480 -0
- requirements.txt +12 -12
app.py
CHANGED
|
@@ -1,479 +1,60 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
Agent2Robot -
|
| 4 |
-
|
| 5 |
-
Track 3: Agentic Demo Showcase
|
| 6 |
"""
|
| 7 |
|
| 8 |
-
import
|
| 9 |
-
import ssl
|
| 10 |
-
import time
|
| 11 |
-
import json
|
| 12 |
-
import tempfile
|
| 13 |
-
from datetime import datetime
|
| 14 |
-
from pathlib import Path
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
pass
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
# Import Gradio with error handling
|
| 29 |
-
GRADIO_AVAILABLE = False
|
| 30 |
-
try:
|
| 31 |
-
import gradio as gr
|
| 32 |
-
GRADIO_AVAILABLE = True
|
| 33 |
-
print("✓ Gradio imported successfully")
|
| 34 |
-
except Exception as e:
|
| 35 |
-
print(f"⚠ Gradio import failed: {e}")
|
| 36 |
-
exit(1)
|
| 37 |
-
|
| 38 |
-
# Import backend components
|
| 39 |
-
from main_orchestrator import HackathonVehicleDesigner
|
| 40 |
-
|
| 41 |
-
# Global configuration
|
| 42 |
-
MAX_ITERATIONS = 5
|
| 43 |
-
designer = HackathonVehicleDesigner()
|
| 44 |
-
|
| 45 |
-
def ui_function_wrapper(vehicle_type, user_description):
|
| 46 |
-
"""
|
| 47 |
-
Main UI wrapper function that yields real-time updates to multiple Gradio components
|
| 48 |
-
Returns tuples in the order: process_log, current_design_specs, progress_bar,
|
| 49 |
-
final_status, simulation_video, best_design_specs, download_json,
|
| 50 |
-
performance_summary, llm_rationale
|
| 51 |
-
"""
|
| 52 |
-
global designer
|
| 53 |
-
|
| 54 |
-
# Reset designer for new task
|
| 55 |
-
designer.reset_design_session()
|
| 56 |
-
designer.vehicle_type = vehicle_type.lower()
|
| 57 |
-
designer.user_task_description = user_description
|
| 58 |
-
|
| 59 |
-
# Initial setup - yield initial states
|
| 60 |
-
yield (
|
| 61 |
-
"🚀 Initializing Agent2Robot system...\n", # process_log_output
|
| 62 |
-
{}, # current_design_specs_output
|
| 63 |
-
0, # progress_bar_output
|
| 64 |
-
"", # final_status_output
|
| 65 |
-
None, # simulation_video_output
|
| 66 |
-
{}, # best_design_specs_output
|
| 67 |
-
None, # download_json_output
|
| 68 |
-
"", # performance_summary_output
|
| 69 |
-
"" # llm_rationale_output
|
| 70 |
-
)
|
| 71 |
-
|
| 72 |
-
# Parse user criteria
|
| 73 |
-
designer.log_process_step("🎯 Analyzing user task and success criteria...")
|
| 74 |
-
criteria = designer.parse_user_task_for_criteria(user_description)
|
| 75 |
-
|
| 76 |
-
designer.log_process_step(f"📋 Interpreted success criteria:")
|
| 77 |
-
for criterion in criteria:
|
| 78 |
-
designer.log_process_step(f" • {criterion}")
|
| 79 |
-
|
| 80 |
-
# Update with criteria interpretation
|
| 81 |
-
current_log = "\n".join(designer.process_log)
|
| 82 |
-
yield (
|
| 83 |
-
current_log, # process_log_output
|
| 84 |
-
{"interpreted_criteria": criteria}, # current_design_specs_output
|
| 85 |
-
0, # progress_bar_output
|
| 86 |
-
"", # final_status_output
|
| 87 |
-
None, # simulation_video_output
|
| 88 |
-
{}, # best_design_specs_output
|
| 89 |
-
None, # download_json_output
|
| 90 |
-
"", # performance_summary_output
|
| 91 |
-
"" # llm_rationale_output
|
| 92 |
-
)
|
| 93 |
-
|
| 94 |
-
# Start design process
|
| 95 |
-
designer.log_process_step(f"🚀 Starting {vehicle_type} design process...")
|
| 96 |
-
designer.log_process_step(f"🎯 Target: {user_description}")
|
| 97 |
-
|
| 98 |
-
current_log = "\n".join(designer.process_log)
|
| 99 |
-
yield (
|
| 100 |
-
current_log, # process_log_output
|
| 101 |
-
{"status": "Design process starting..."}, # current_design_specs_output
|
| 102 |
-
0, # progress_bar_output
|
| 103 |
-
"", # final_status_output
|
| 104 |
-
None, # simulation_video_output
|
| 105 |
-
{}, # best_design_specs_output
|
| 106 |
-
None, # download_json_output
|
| 107 |
-
"", # performance_summary_output
|
| 108 |
-
"" # llm_rationale_output
|
| 109 |
-
)
|
| 110 |
-
|
| 111 |
-
# Run iterations
|
| 112 |
-
for iteration in range(1, MAX_ITERATIONS + 1):
|
| 113 |
-
designer.log_process_step(f"\n=== Starting Iteration {iteration}/{MAX_ITERATIONS} ===")
|
| 114 |
|
| 115 |
-
# Update progress at start of iteration
|
| 116 |
-
current_log = "\n".join(designer.process_log)
|
| 117 |
-
progress_value = (iteration - 0.5) / MAX_ITERATIONS * 100 # Convert to percentage
|
| 118 |
-
yield (
|
| 119 |
-
current_log, # process_log_output
|
| 120 |
-
{"current_iteration": iteration, "max_iterations": MAX_ITERATIONS, "status": "Running..."}, # current_design_specs_output
|
| 121 |
-
progress_value, # progress_bar_output
|
| 122 |
-
"", # final_status_output
|
| 123 |
-
None, # simulation_video_output
|
| 124 |
-
{}, # best_design_specs_output
|
| 125 |
-
None, # download_json_output
|
| 126 |
-
"", # performance_summary_output
|
| 127 |
-
"" # llm_rationale_output
|
| 128 |
-
)
|
| 129 |
-
|
| 130 |
-
# Run the iteration
|
| 131 |
-
try:
|
| 132 |
-
success = designer.run_single_iteration(iteration)
|
| 133 |
-
|
| 134 |
-
# Get current design specs for display
|
| 135 |
-
if designer.all_attempts:
|
| 136 |
-
current_attempt = designer.all_attempts[-1]
|
| 137 |
-
current_specs = current_attempt['vehicle_specs']
|
| 138 |
-
design_reasoning = current_attempt.get('design_reasoning', 'No reasoning provided')
|
| 139 |
-
|
| 140 |
-
# Update with current iteration results
|
| 141 |
-
current_log = "\n".join(designer.process_log)
|
| 142 |
-
progress_value = iteration / MAX_ITERATIONS * 100
|
| 143 |
-
|
| 144 |
-
current_specs_display = {
|
| 145 |
-
"iteration": iteration,
|
| 146 |
-
"vehicle_specs": current_specs,
|
| 147 |
-
"design_reasoning_preview": design_reasoning[:200] + "..." if len(design_reasoning) > 200 else design_reasoning,
|
| 148 |
-
"status": "✅ SUCCESS" if success else "🔄 Completed - Evaluating..."
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
yield (
|
| 152 |
-
current_log, # process_log_output
|
| 153 |
-
current_specs_display, # current_design_specs_output
|
| 154 |
-
progress_value, # progress_bar_output
|
| 155 |
-
"", # final_status_output
|
| 156 |
-
None, # simulation_video_output
|
| 157 |
-
{}, # best_design_specs_output
|
| 158 |
-
None, # download_json_output
|
| 159 |
-
"", # performance_summary_output
|
| 160 |
-
"" # llm_rationale_output
|
| 161 |
-
)
|
| 162 |
-
|
| 163 |
-
if success:
|
| 164 |
-
designer.log_process_step("🎉 SUCCESS! Design meets all criteria!")
|
| 165 |
-
break
|
| 166 |
-
|
| 167 |
-
except Exception as e:
|
| 168 |
-
designer.log_process_step(f"❌ Error in iteration {iteration}: {str(e)}")
|
| 169 |
-
current_log = "\n".join(designer.process_log)
|
| 170 |
-
progress_value = iteration / MAX_ITERATIONS * 100
|
| 171 |
-
yield (
|
| 172 |
-
current_log, # process_log_output
|
| 173 |
-
{"error": f"Iteration {iteration} failed", "details": str(e)}, # current_design_specs_output
|
| 174 |
-
progress_value, # progress_bar_output
|
| 175 |
-
"", # final_status_output
|
| 176 |
-
None, # simulation_video_output
|
| 177 |
-
{}, # best_design_specs_output
|
| 178 |
-
None, # download_json_output
|
| 179 |
-
"", # performance_summary_output
|
| 180 |
-
"" # llm_rationale_output
|
| 181 |
-
)
|
| 182 |
-
|
| 183 |
-
# Generate final results
|
| 184 |
-
designer.log_process_step("📊 Generating final results and visualizations...")
|
| 185 |
-
current_log = "\n".join(designer.process_log)
|
| 186 |
-
yield (
|
| 187 |
-
current_log, # process_log_output
|
| 188 |
-
{"status": "Generating final results..."}, # current_design_specs_output
|
| 189 |
-
100, # progress_bar_output - complete
|
| 190 |
-
"", # final_status_output
|
| 191 |
-
None, # simulation_video_output
|
| 192 |
-
{}, # best_design_specs_output
|
| 193 |
-
None, # download_json_output
|
| 194 |
-
"", # performance_summary_output
|
| 195 |
-
"" # llm_rationale_output
|
| 196 |
-
)
|
| 197 |
-
|
| 198 |
-
# Prepare final outputs
|
| 199 |
-
if designer.overall_success:
|
| 200 |
-
final_status = "## 🎉 SUCCESS!\n\nThe LLM agent successfully designed a vehicle that meets all criteria!"
|
| 201 |
-
status_emoji = "✅"
|
| 202 |
-
else:
|
| 203 |
-
final_status = "## ⚠️ PROCESS COMPLETED\n\nThe agent completed all iterations. Showing best attempt found."
|
| 204 |
-
status_emoji = "🔄"
|
| 205 |
-
|
| 206 |
-
# Get best design specs
|
| 207 |
-
best_specs = designer.best_attempt['vehicle_specs'] if designer.best_attempt else {}
|
| 208 |
-
|
| 209 |
-
# Create visualization
|
| 210 |
-
simulation_gif_path = None
|
| 211 |
-
try:
|
| 212 |
-
simulation_gif_path = designer.create_final_visualization()
|
| 213 |
-
except Exception as e:
|
| 214 |
-
designer.log_process_step(f"⚠️ Error creating visualization: {str(e)}")
|
| 215 |
-
|
| 216 |
-
# Format performance summary
|
| 217 |
-
if designer.best_attempt:
|
| 218 |
-
eval_results = designer.best_attempt['evaluation_results']
|
| 219 |
-
performance_summary = f"""## 📊 Performance Summary of Best Design
|
| 220 |
-
|
| 221 |
-
**Iteration Found**: {designer.best_iteration}/{len(designer.all_attempts)}
|
| 222 |
-
**Final Position**: {eval_results.get('final_robot_x_position', 0.0):.3f}m
|
| 223 |
-
**Crossed Obstacle**: {'✅ Yes' if eval_results.get('robot_crossed_obstacle', False) else '❌ No'}
|
| 224 |
-
**Remained Stable**: {'✅ Yes' if eval_results.get('robot_remains_upright', False) else '❌ No'}
|
| 225 |
-
**Clean Pass**: {'✅ Yes' if eval_results.get('no_significant_collision_with_obstacle_during_pass', False) else '❌ No'}
|
| 226 |
-
|
| 227 |
-
**Overall Success**: {'✅ ACHIEVED' if eval_results.get('overall_success', False) else '❌ NOT FULLY ACHIEVED'}
|
| 228 |
-
|
| 229 |
-
**Target Distance**: 0.8m (obstacle clearance)
|
| 230 |
-
**Achieved Distance**: {eval_results.get('final_robot_x_position', 0.0):.3f}m
|
| 231 |
-
**Success Rate**: {100 if eval_results.get('overall_success', False) else 0}%
|
| 232 |
-
|
| 233 |
-
{status_emoji} **Status**: {'Complete Success' if designer.overall_success else 'Best Effort'}
|
| 234 |
-
"""
|
| 235 |
-
else:
|
| 236 |
-
performance_summary = "## ❌ No successful attempts recorded\n\nThe system was unable to generate valid designs."
|
| 237 |
-
|
| 238 |
-
# Get LLM rationale
|
| 239 |
-
llm_rationale = designer.best_attempt['design_reasoning'] if designer.best_attempt else "No design reasoning available"
|
| 240 |
-
|
| 241 |
-
# Create downloadable specs
|
| 242 |
-
download_specs_path = None
|
| 243 |
-
try:
|
| 244 |
-
download_specs_path = designer.save_design_specs_json()
|
| 245 |
-
except Exception as e:
|
| 246 |
-
designer.log_process_step(f"⚠️ Error saving specs: {str(e)}")
|
| 247 |
-
|
| 248 |
-
# Final log update
|
| 249 |
-
designer.log_process_step(f"\n🏁 DESIGN PROCESS COMPLETED")
|
| 250 |
-
designer.log_process_step(f"📊 Total iterations: {len(designer.all_attempts)}")
|
| 251 |
-
designer.log_process_step(f"🏆 Best iteration: {designer.best_iteration}")
|
| 252 |
-
designer.log_process_step(f"✅ Overall success: {designer.overall_success}")
|
| 253 |
-
|
| 254 |
-
final_log = "\n".join(designer.process_log)
|
| 255 |
-
|
| 256 |
-
# Final yield with all results
|
| 257 |
-
yield (
|
| 258 |
-
final_log, # process_log_output
|
| 259 |
-
{"final_summary": f"Process completed. {len(designer.all_attempts)} iterations run."}, # current_design_specs_output
|
| 260 |
-
100, # progress_bar_output
|
| 261 |
-
final_status, # final_status_output
|
| 262 |
-
simulation_gif_path, # simulation_video_output
|
| 263 |
-
best_specs, # best_design_specs_output
|
| 264 |
-
download_specs_path, # download_json_output
|
| 265 |
-
performance_summary, # performance_summary_output
|
| 266 |
-
llm_rationale # llm_rationale_output
|
| 267 |
-
)
|
| 268 |
-
|
| 269 |
-
def create_agent2robot_interface():
|
| 270 |
-
"""Create the Agent2Robot Gradio interface"""
|
| 271 |
-
|
| 272 |
-
# Custom CSS for better appearance
|
| 273 |
-
custom_css = """
|
| 274 |
-
.main-header {
|
| 275 |
-
text-align: center;
|
| 276 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 277 |
-
color: white;
|
| 278 |
-
padding: 30px;
|
| 279 |
-
border-radius: 15px;
|
| 280 |
-
margin-bottom: 20px;
|
| 281 |
-
box-shadow: 0 8px 16px rgba(0,0,0,0.1);
|
| 282 |
-
}
|
| 283 |
-
.process-log {
|
| 284 |
-
font-family: 'Courier New', monospace;
|
| 285 |
-
font-size: 12px;
|
| 286 |
-
line-height: 1.4;
|
| 287 |
-
}
|
| 288 |
-
.success-indicator {
|
| 289 |
-
background: linear-gradient(90deg, #4CAF50, #45a049);
|
| 290 |
-
color: white;
|
| 291 |
-
padding: 10px;
|
| 292 |
-
border-radius: 8px;
|
| 293 |
-
margin: 5px 0;
|
| 294 |
-
}
|
| 295 |
-
.iteration-info {
|
| 296 |
-
background: linear-gradient(90deg, #2196F3, #1976D2);
|
| 297 |
-
color: white;
|
| 298 |
-
padding: 8px;
|
| 299 |
-
border-radius: 6px;
|
| 300 |
-
margin: 3px 0;
|
| 301 |
-
}
|
| 302 |
-
"""
|
| 303 |
-
|
| 304 |
-
with gr.Blocks(
|
| 305 |
-
title="🤖🚁 Agent2Robot - LLM Vehicle Designer",
|
| 306 |
-
theme=gr.themes.Soft(),
|
| 307 |
-
css=custom_css
|
| 308 |
-
) as demo:
|
| 309 |
-
|
| 310 |
-
# Header Section
|
| 311 |
-
gr.HTML("""
|
| 312 |
-
<div class="main-header">
|
| 313 |
-
<h1>🤖🚁 Agent2Robot</h1>
|
| 314 |
-
<h2>LLM-Agent-Designed Obstacle-Passing Vehicle System</h2>
|
| 315 |
-
<p><strong>Hackathon Submission - Track 3: Agentic Demo Showcase</strong></p>
|
| 316 |
-
<p>Describe your desired vehicle and task in natural language, then watch our AI agent design, simulate, and optimize it in real-time!</p>
|
| 317 |
-
</div>
|
| 318 |
-
""")
|
| 319 |
-
|
| 320 |
-
# Main Input Section
|
| 321 |
with gr.Row():
|
| 322 |
-
with gr.Column(
|
| 323 |
-
gr.
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
label="1. Choose Vehicle Type",
|
| 328 |
-
value="Robot",
|
| 329 |
-
info="Select whether you want a ground robot or flying drone"
|
| 330 |
-
)
|
| 331 |
-
|
| 332 |
-
user_description_input = gr.Textbox(
|
| 333 |
-
lines=5,
|
| 334 |
-
label="2. Describe Vehicle's Task & Success Criteria",
|
| 335 |
-
placeholder="e.g., 'Design a robot that can cross the 5cm box obstacle quickly and without tipping over, then stop safely.' or 'Create a drone that flies over the wall, lands gently 1 meter beyond it, and remains stable.'",
|
| 336 |
-
value="Design a robot that can cross the 5cm high obstacle smoothly and come to a controlled stop."
|
| 337 |
-
)
|
| 338 |
-
|
| 339 |
-
start_button = gr.Button(
|
| 340 |
-
"🚀 Start AI Design Process",
|
| 341 |
-
variant="primary",
|
| 342 |
-
size="lg"
|
| 343 |
)
|
| 344 |
-
|
| 345 |
-
gr.Markdown("""
|
| 346 |
-
### 📋 Environment Info
|
| 347 |
-
- **Obstacle**: 5cm high × 50cm wide box
|
| 348 |
-
- **Success Target**: Vehicle reaches x > 0.8m
|
| 349 |
-
- **Physics**: Real-time PyBullet simulation
|
| 350 |
-
- **Max Iterations**: 5 design attempts
|
| 351 |
-
""")
|
| 352 |
|
| 353 |
-
with gr.Column(
|
| 354 |
-
gr.
|
| 355 |
-
|
| 356 |
-
process_log_output = gr.Textbox(
|
| 357 |
-
label="🤖 AI Agent - Live Process Log",
|
| 358 |
-
lines=15,
|
| 359 |
-
interactive=False,
|
| 360 |
-
show_copy_button=True,
|
| 361 |
-
elem_classes=["process-log"],
|
| 362 |
-
placeholder="Process log will appear here in real-time as the AI agent works...",
|
| 363 |
value=""
|
| 364 |
)
|
| 365 |
-
|
| 366 |
-
with gr.Row():
|
| 367 |
-
current_design_specs_output = gr.JSON(
|
| 368 |
-
label="⚙️ Current Design Specs Being Tested",
|
| 369 |
-
value={}
|
| 370 |
-
)
|
| 371 |
-
|
| 372 |
-
progress_bar_output = gr.Slider(
|
| 373 |
-
minimum=0,
|
| 374 |
-
maximum=100,
|
| 375 |
-
step=1,
|
| 376 |
-
label="Progress (%)",
|
| 377 |
-
interactive=False,
|
| 378 |
-
show_label=True,
|
| 379 |
-
value=0
|
| 380 |
-
)
|
| 381 |
-
|
| 382 |
-
# Results Section
|
| 383 |
-
with gr.Accordion("🏆 Final Results & Design Specifications", open=True) as results_accordion:
|
| 384 |
-
final_status_output = gr.Markdown(
|
| 385 |
-
label="🏁 Final Run Status",
|
| 386 |
-
value="Waiting for process to complete..."
|
| 387 |
-
)
|
| 388 |
-
|
| 389 |
-
with gr.Row():
|
| 390 |
-
with gr.Column(scale=2):
|
| 391 |
-
simulation_video_output = gr.Image(
|
| 392 |
-
label="🎬 Simulation of Best Design's Trial",
|
| 393 |
-
interactive=False,
|
| 394 |
-
height=300,
|
| 395 |
-
value=None
|
| 396 |
-
)
|
| 397 |
-
|
| 398 |
-
performance_summary_output = gr.Markdown(
|
| 399 |
-
label="📊 Performance Summary of Best Design",
|
| 400 |
-
value=""
|
| 401 |
-
)
|
| 402 |
-
|
| 403 |
-
with gr.Column(scale=1):
|
| 404 |
-
best_design_specs_output = gr.JSON(
|
| 405 |
-
label="🔩 Best Vehicle Design Specifications",
|
| 406 |
-
show_label=True,
|
| 407 |
-
value={}
|
| 408 |
-
)
|
| 409 |
-
|
| 410 |
-
download_json_output = gr.File(
|
| 411 |
-
label="📄 Download Best Design Specs (JSON)",
|
| 412 |
-
file_count="single",
|
| 413 |
-
type="filepath",
|
| 414 |
-
interactive=True,
|
| 415 |
-
value=None
|
| 416 |
-
)
|
| 417 |
-
|
| 418 |
-
llm_rationale_output = gr.Textbox(
|
| 419 |
-
label="💡 LLM's Design Rationale",
|
| 420 |
-
lines=6,
|
| 421 |
-
interactive=False,
|
| 422 |
-
show_copy_button=True,
|
| 423 |
-
value=""
|
| 424 |
-
)
|
| 425 |
|
| 426 |
-
|
| 427 |
-
start_button.click(
|
| 428 |
-
fn=ui_function_wrapper,
|
| 429 |
-
inputs=[vehicle_type_input, user_description_input],
|
| 430 |
-
outputs=[
|
| 431 |
-
process_log_output,
|
| 432 |
-
current_design_specs_output,
|
| 433 |
-
progress_bar_output,
|
| 434 |
-
final_status_output,
|
| 435 |
-
simulation_video_output,
|
| 436 |
-
best_design_specs_output,
|
| 437 |
-
download_json_output,
|
| 438 |
-
performance_summary_output,
|
| 439 |
-
llm_rationale_output
|
| 440 |
-
],
|
| 441 |
-
show_progress=False # We handle progress manually
|
| 442 |
-
)
|
| 443 |
|
| 444 |
-
# Information Footer
|
| 445 |
gr.Markdown("---")
|
| 446 |
-
gr.Markdown(""
|
| 447 |
-
## 🔬 How the Agentic AI Works
|
| 448 |
-
|
| 449 |
-
1. **🎯 Criteria Interpretation**: AI analyzes your natural language task and defines measurable success conditions
|
| 450 |
-
2. **🔧 Intelligent Design**: LLM proposes vehicle specifications based on physics principles and your requirements
|
| 451 |
-
3. **⚗️ Physics Simulation**: Each design is tested in accurate PyBullet physics simulation with real obstacles
|
| 452 |
-
4. **📊 Performance Analysis**: Results are evaluated against your interpreted criteria with detailed metrics
|
| 453 |
-
5. **🔄 Iterative Learning**: AI uses simulation feedback to refine and improve designs automatically
|
| 454 |
-
6. **🏆 Best Design Selection**: System tracks performance and presents the optimal solution found
|
| 455 |
-
|
| 456 |
-
**🚀 Innovation**: This demonstrates autonomous AI that goes beyond text generation - it's an agent that designs, tests, learns, and optimizes physical systems to meet user-defined functional requirements.
|
| 457 |
-
""")
|
| 458 |
|
| 459 |
return demo
|
| 460 |
|
| 461 |
if __name__ == "__main__":
|
| 462 |
-
print("
|
| 463 |
-
print("=" *
|
| 464 |
-
print("🚀
|
| 465 |
|
| 466 |
try:
|
| 467 |
-
|
| 468 |
-
app = create_agent2robot_interface()
|
| 469 |
app.launch(
|
| 470 |
server_name="0.0.0.0",
|
| 471 |
server_port=7860,
|
| 472 |
-
share=False,
|
| 473 |
show_error=True,
|
| 474 |
inbrowser=True,
|
| 475 |
quiet=False
|
| 476 |
)
|
| 477 |
except Exception as e:
|
| 478 |
-
print(f"❌ Error launching app: {e}")
|
| 479 |
-
print("
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Agent2Robot - Minimal Test App
|
| 4 |
+
Systematic Debugging - Phase 1
|
|
|
|
| 5 |
"""
|
| 6 |
|
| 7 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def dummy_function(name):
|
| 10 |
+
"""Simple test function"""
|
| 11 |
+
if not name:
|
| 12 |
+
name = "World"
|
| 13 |
+
return f"Hello {name}! The basic Gradio app is working."
|
|
|
|
| 14 |
|
| 15 |
+
def create_minimal_app():
|
| 16 |
+
"""Create minimal Gradio interface for testing"""
|
| 17 |
+
with gr.Blocks(title="Agent2Robot - Minimal Test") as demo:
|
| 18 |
+
gr.Markdown("# 🔧 Agent2Robot - Minimal Test App")
|
| 19 |
+
gr.Markdown("**Phase 1: Testing basic Gradio functionality**")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
with gr.Row():
|
| 22 |
+
with gr.Column():
|
| 23 |
+
inp = gr.Textbox(
|
| 24 |
+
label="Input",
|
| 25 |
+
placeholder="Enter your name...",
|
| 26 |
+
value=""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
)
|
| 28 |
+
btn = gr.Button("Submit", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
+
with gr.Column():
|
| 31 |
+
out = gr.Textbox(
|
| 32 |
+
label="Output",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
value=""
|
| 34 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
+
btn.click(fn=dummy_function, inputs=inp, outputs=out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
|
|
|
| 38 |
gr.Markdown("---")
|
| 39 |
+
gr.Markdown("**Status**: If you see this page, basic Gradio components are working correctly.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
return demo
|
| 42 |
|
| 43 |
if __name__ == "__main__":
|
| 44 |
+
print("🔧 Agent2Robot - Minimal Test App")
|
| 45 |
+
print("=" * 50)
|
| 46 |
+
print("🚀 Testing basic Gradio functionality...")
|
| 47 |
|
| 48 |
try:
|
| 49 |
+
app = create_minimal_app()
|
|
|
|
| 50 |
app.launch(
|
| 51 |
server_name="0.0.0.0",
|
| 52 |
server_port=7860,
|
| 53 |
+
share=False,
|
| 54 |
show_error=True,
|
| 55 |
inbrowser=True,
|
| 56 |
quiet=False
|
| 57 |
)
|
| 58 |
except Exception as e:
|
| 59 |
+
print(f"❌ Error launching minimal app: {e}")
|
| 60 |
+
print("Basic Gradio functionality is failing.")
|
app_backup.py
ADDED
|
@@ -0,0 +1,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
+
|
| 9 |
+
import os
|
| 10 |
+
import ssl
|
| 11 |
+
import time
|
| 12 |
+
import json
|
| 13 |
+
import tempfile
|
| 14 |
+
from datetime import datetime
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
|
| 17 |
+
# SSL workaround for Gradio issues
|
| 18 |
+
try:
|
| 19 |
+
import certifi
|
| 20 |
+
os.environ['SSL_CERT_FILE'] = certifi.where()
|
| 21 |
+
except ImportError:
|
| 22 |
+
pass
|
| 23 |
+
|
| 24 |
+
try:
|
| 25 |
+
ssl._create_default_https_context = ssl._create_unverified_context
|
| 26 |
+
except AttributeError:
|
| 27 |
+
pass
|
| 28 |
+
|
| 29 |
+
# Import Gradio with error handling
|
| 30 |
+
GRADIO_AVAILABLE = False
|
| 31 |
+
try:
|
| 32 |
+
import gradio as gr
|
| 33 |
+
GRADIO_AVAILABLE = True
|
| 34 |
+
print("✓ Gradio imported successfully")
|
| 35 |
+
except Exception as e:
|
| 36 |
+
print(f"⚠ Gradio import failed: {e}")
|
| 37 |
+
exit(1)
|
| 38 |
+
|
| 39 |
+
# Import backend components
|
| 40 |
+
from main_orchestrator import HackathonVehicleDesigner
|
| 41 |
+
|
| 42 |
+
# Global configuration
|
| 43 |
+
MAX_ITERATIONS = 5
|
| 44 |
+
designer = HackathonVehicleDesigner()
|
| 45 |
+
|
| 46 |
+
def ui_function_wrapper(vehicle_type, user_description):
|
| 47 |
+
"""
|
| 48 |
+
Main UI wrapper function that yields real-time updates to multiple Gradio components
|
| 49 |
+
Returns tuples in the order: process_log, current_design_specs, progress_bar,
|
| 50 |
+
final_status, simulation_video, best_design_specs, download_json,
|
| 51 |
+
performance_summary, llm_rationale
|
| 52 |
+
"""
|
| 53 |
+
global designer
|
| 54 |
+
|
| 55 |
+
# Reset designer for new task
|
| 56 |
+
designer.reset_design_session()
|
| 57 |
+
designer.vehicle_type = vehicle_type.lower()
|
| 58 |
+
designer.user_task_description = user_description
|
| 59 |
+
|
| 60 |
+
# Initial setup - yield initial states
|
| 61 |
+
yield (
|
| 62 |
+
"🚀 Initializing Agent2Robot system...\n", # process_log_output
|
| 63 |
+
{}, # current_design_specs_output
|
| 64 |
+
0, # progress_bar_output
|
| 65 |
+
"", # final_status_output
|
| 66 |
+
None, # simulation_video_output
|
| 67 |
+
{}, # best_design_specs_output
|
| 68 |
+
None, # download_json_output
|
| 69 |
+
"", # performance_summary_output
|
| 70 |
+
"" # llm_rationale_output
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
# Parse user criteria
|
| 74 |
+
designer.log_process_step("🎯 Analyzing user task and success criteria...")
|
| 75 |
+
criteria = designer.parse_user_task_for_criteria(user_description)
|
| 76 |
+
|
| 77 |
+
designer.log_process_step(f"📋 Interpreted success criteria:")
|
| 78 |
+
for criterion in criteria:
|
| 79 |
+
designer.log_process_step(f" • {criterion}")
|
| 80 |
+
|
| 81 |
+
# Update with criteria interpretation
|
| 82 |
+
current_log = "\n".join(designer.process_log)
|
| 83 |
+
yield (
|
| 84 |
+
current_log, # process_log_output
|
| 85 |
+
{"interpreted_criteria": criteria}, # current_design_specs_output
|
| 86 |
+
0, # progress_bar_output
|
| 87 |
+
"", # final_status_output
|
| 88 |
+
None, # simulation_video_output
|
| 89 |
+
{}, # best_design_specs_output
|
| 90 |
+
None, # download_json_output
|
| 91 |
+
"", # performance_summary_output
|
| 92 |
+
"" # llm_rationale_output
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
+
# Start design process
|
| 96 |
+
designer.log_process_step(f"🚀 Starting {vehicle_type} design process...")
|
| 97 |
+
designer.log_process_step(f"🎯 Target: {user_description}")
|
| 98 |
+
|
| 99 |
+
current_log = "\n".join(designer.process_log)
|
| 100 |
+
yield (
|
| 101 |
+
current_log, # process_log_output
|
| 102 |
+
{"status": "Design process starting..."}, # current_design_specs_output
|
| 103 |
+
0, # progress_bar_output
|
| 104 |
+
"", # final_status_output
|
| 105 |
+
None, # simulation_video_output
|
| 106 |
+
{}, # best_design_specs_output
|
| 107 |
+
None, # download_json_output
|
| 108 |
+
"", # performance_summary_output
|
| 109 |
+
"" # llm_rationale_output
|
| 110 |
+
)
|
| 111 |
+
|
| 112 |
+
# Run iterations
|
| 113 |
+
for iteration in range(1, MAX_ITERATIONS + 1):
|
| 114 |
+
designer.log_process_step(f"\n=== Starting Iteration {iteration}/{MAX_ITERATIONS} ===")
|
| 115 |
+
|
| 116 |
+
# Update progress at start of iteration
|
| 117 |
+
current_log = "\n".join(designer.process_log)
|
| 118 |
+
progress_value = (iteration - 0.5) / MAX_ITERATIONS * 100 # Convert to percentage
|
| 119 |
+
yield (
|
| 120 |
+
current_log, # process_log_output
|
| 121 |
+
{"current_iteration": iteration, "max_iterations": MAX_ITERATIONS, "status": "Running..."}, # current_design_specs_output
|
| 122 |
+
progress_value, # progress_bar_output
|
| 123 |
+
"", # final_status_output
|
| 124 |
+
None, # simulation_video_output
|
| 125 |
+
{}, # best_design_specs_output
|
| 126 |
+
None, # download_json_output
|
| 127 |
+
"", # performance_summary_output
|
| 128 |
+
"" # llm_rationale_output
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
+
# Run the iteration
|
| 132 |
+
try:
|
| 133 |
+
success = designer.run_single_iteration(iteration)
|
| 134 |
+
|
| 135 |
+
# Get current design specs for display
|
| 136 |
+
if designer.all_attempts:
|
| 137 |
+
current_attempt = designer.all_attempts[-1]
|
| 138 |
+
current_specs = current_attempt['vehicle_specs']
|
| 139 |
+
design_reasoning = current_attempt.get('design_reasoning', 'No reasoning provided')
|
| 140 |
+
|
| 141 |
+
# Update with current iteration results
|
| 142 |
+
current_log = "\n".join(designer.process_log)
|
| 143 |
+
progress_value = iteration / MAX_ITERATIONS * 100
|
| 144 |
+
|
| 145 |
+
current_specs_display = {
|
| 146 |
+
"iteration": iteration,
|
| 147 |
+
"vehicle_specs": current_specs,
|
| 148 |
+
"design_reasoning_preview": design_reasoning[:200] + "..." if len(design_reasoning) > 200 else design_reasoning,
|
| 149 |
+
"status": "✅ SUCCESS" if success else "🔄 Completed - Evaluating..."
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
yield (
|
| 153 |
+
current_log, # process_log_output
|
| 154 |
+
current_specs_display, # current_design_specs_output
|
| 155 |
+
progress_value, # progress_bar_output
|
| 156 |
+
"", # final_status_output
|
| 157 |
+
None, # simulation_video_output
|
| 158 |
+
{}, # best_design_specs_output
|
| 159 |
+
None, # download_json_output
|
| 160 |
+
"", # performance_summary_output
|
| 161 |
+
"" # llm_rationale_output
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
if success:
|
| 165 |
+
designer.log_process_step("🎉 SUCCESS! Design meets all criteria!")
|
| 166 |
+
break
|
| 167 |
+
|
| 168 |
+
except Exception as e:
|
| 169 |
+
designer.log_process_step(f"❌ Error in iteration {iteration}: {str(e)}")
|
| 170 |
+
current_log = "\n".join(designer.process_log)
|
| 171 |
+
progress_value = iteration / MAX_ITERATIONS * 100
|
| 172 |
+
yield (
|
| 173 |
+
current_log, # process_log_output
|
| 174 |
+
{"error": f"Iteration {iteration} failed", "details": str(e)}, # current_design_specs_output
|
| 175 |
+
progress_value, # progress_bar_output
|
| 176 |
+
"", # final_status_output
|
| 177 |
+
None, # simulation_video_output
|
| 178 |
+
{}, # best_design_specs_output
|
| 179 |
+
None, # download_json_output
|
| 180 |
+
"", # performance_summary_output
|
| 181 |
+
"" # llm_rationale_output
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
# Generate final results
|
| 185 |
+
designer.log_process_step("📊 Generating final results and visualizations...")
|
| 186 |
+
current_log = "\n".join(designer.process_log)
|
| 187 |
+
yield (
|
| 188 |
+
current_log, # process_log_output
|
| 189 |
+
{"status": "Generating final results..."}, # current_design_specs_output
|
| 190 |
+
100, # progress_bar_output - complete
|
| 191 |
+
"", # final_status_output
|
| 192 |
+
None, # simulation_video_output
|
| 193 |
+
{}, # best_design_specs_output
|
| 194 |
+
None, # download_json_output
|
| 195 |
+
"", # performance_summary_output
|
| 196 |
+
"" # llm_rationale_output
|
| 197 |
+
)
|
| 198 |
+
|
| 199 |
+
# Prepare final outputs
|
| 200 |
+
if designer.overall_success:
|
| 201 |
+
final_status = "## 🎉 SUCCESS!\n\nThe LLM agent successfully designed a vehicle that meets all criteria!"
|
| 202 |
+
status_emoji = "✅"
|
| 203 |
+
else:
|
| 204 |
+
final_status = "## ⚠️ PROCESS COMPLETED\n\nThe agent completed all iterations. Showing best attempt found."
|
| 205 |
+
status_emoji = "🔄"
|
| 206 |
+
|
| 207 |
+
# Get best design specs
|
| 208 |
+
best_specs = designer.best_attempt['vehicle_specs'] if designer.best_attempt else {}
|
| 209 |
+
|
| 210 |
+
# Create visualization
|
| 211 |
+
simulation_gif_path = None
|
| 212 |
+
try:
|
| 213 |
+
simulation_gif_path = designer.create_final_visualization()
|
| 214 |
+
except Exception as e:
|
| 215 |
+
designer.log_process_step(f"⚠️ Error creating visualization: {str(e)}")
|
| 216 |
+
|
| 217 |
+
# Format performance summary
|
| 218 |
+
if designer.best_attempt:
|
| 219 |
+
eval_results = designer.best_attempt['evaluation_results']
|
| 220 |
+
performance_summary = f"""## 📊 Performance Summary of Best Design
|
| 221 |
+
|
| 222 |
+
**Iteration Found**: {designer.best_iteration}/{len(designer.all_attempts)}
|
| 223 |
+
**Final Position**: {eval_results.get('final_robot_x_position', 0.0):.3f}m
|
| 224 |
+
**Crossed Obstacle**: {'✅ Yes' if eval_results.get('robot_crossed_obstacle', False) else '❌ No'}
|
| 225 |
+
**Remained Stable**: {'✅ Yes' if eval_results.get('robot_remains_upright', False) else '❌ No'}
|
| 226 |
+
**Clean Pass**: {'✅ Yes' if eval_results.get('no_significant_collision_with_obstacle_during_pass', False) else '❌ No'}
|
| 227 |
+
|
| 228 |
+
**Overall Success**: {'✅ ACHIEVED' if eval_results.get('overall_success', False) else '❌ NOT FULLY ACHIEVED'}
|
| 229 |
+
|
| 230 |
+
**Target Distance**: 0.8m (obstacle clearance)
|
| 231 |
+
**Achieved Distance**: {eval_results.get('final_robot_x_position', 0.0):.3f}m
|
| 232 |
+
**Success Rate**: {100 if eval_results.get('overall_success', False) else 0}%
|
| 233 |
+
|
| 234 |
+
{status_emoji} **Status**: {'Complete Success' if designer.overall_success else 'Best Effort'}
|
| 235 |
+
"""
|
| 236 |
+
else:
|
| 237 |
+
performance_summary = "## ❌ No successful attempts recorded\n\nThe system was unable to generate valid designs."
|
| 238 |
+
|
| 239 |
+
# Get LLM rationale
|
| 240 |
+
llm_rationale = designer.best_attempt['design_reasoning'] if designer.best_attempt else "No design reasoning available"
|
| 241 |
+
|
| 242 |
+
# Create downloadable specs
|
| 243 |
+
download_specs_path = None
|
| 244 |
+
try:
|
| 245 |
+
download_specs_path = designer.save_design_specs_json()
|
| 246 |
+
except Exception as e:
|
| 247 |
+
designer.log_process_step(f"⚠️ Error saving specs: {str(e)}")
|
| 248 |
+
|
| 249 |
+
# Final log update
|
| 250 |
+
designer.log_process_step(f"\n🏁 DESIGN PROCESS COMPLETED")
|
| 251 |
+
designer.log_process_step(f"📊 Total iterations: {len(designer.all_attempts)}")
|
| 252 |
+
designer.log_process_step(f"🏆 Best iteration: {designer.best_iteration}")
|
| 253 |
+
designer.log_process_step(f"✅ Overall success: {designer.overall_success}")
|
| 254 |
+
|
| 255 |
+
final_log = "\n".join(designer.process_log)
|
| 256 |
+
|
| 257 |
+
# Final yield with all results
|
| 258 |
+
yield (
|
| 259 |
+
final_log, # process_log_output
|
| 260 |
+
{"final_summary": f"Process completed. {len(designer.all_attempts)} iterations run."}, # current_design_specs_output
|
| 261 |
+
100, # progress_bar_output
|
| 262 |
+
final_status, # final_status_output
|
| 263 |
+
simulation_gif_path, # simulation_video_output
|
| 264 |
+
best_specs, # best_design_specs_output
|
| 265 |
+
download_specs_path, # download_json_output
|
| 266 |
+
performance_summary, # performance_summary_output
|
| 267 |
+
llm_rationale # llm_rationale_output
|
| 268 |
+
)
|
| 269 |
+
|
| 270 |
+
def create_agent2robot_interface():
|
| 271 |
+
"""Create the Agent2Robot Gradio interface"""
|
| 272 |
+
|
| 273 |
+
# Custom CSS for better appearance
|
| 274 |
+
custom_css = """
|
| 275 |
+
.main-header {
|
| 276 |
+
text-align: center;
|
| 277 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 278 |
+
color: white;
|
| 279 |
+
padding: 30px;
|
| 280 |
+
border-radius: 15px;
|
| 281 |
+
margin-bottom: 20px;
|
| 282 |
+
box-shadow: 0 8px 16px rgba(0,0,0,0.1);
|
| 283 |
+
}
|
| 284 |
+
.process-log {
|
| 285 |
+
font-family: 'Courier New', monospace;
|
| 286 |
+
font-size: 12px;
|
| 287 |
+
line-height: 1.4;
|
| 288 |
+
}
|
| 289 |
+
.success-indicator {
|
| 290 |
+
background: linear-gradient(90deg, #4CAF50, #45a049);
|
| 291 |
+
color: white;
|
| 292 |
+
padding: 10px;
|
| 293 |
+
border-radius: 8px;
|
| 294 |
+
margin: 5px 0;
|
| 295 |
+
}
|
| 296 |
+
.iteration-info {
|
| 297 |
+
background: linear-gradient(90deg, #2196F3, #1976D2);
|
| 298 |
+
color: white;
|
| 299 |
+
padding: 8px;
|
| 300 |
+
border-radius: 6px;
|
| 301 |
+
margin: 3px 0;
|
| 302 |
+
}
|
| 303 |
+
"""
|
| 304 |
+
|
| 305 |
+
with gr.Blocks(
|
| 306 |
+
title="🤖🚁 Agent2Robot - LLM Vehicle Designer",
|
| 307 |
+
theme=gr.themes.Soft(),
|
| 308 |
+
css=custom_css
|
| 309 |
+
) as demo:
|
| 310 |
+
|
| 311 |
+
# Header Section
|
| 312 |
+
gr.HTML("""
|
| 313 |
+
<div class="main-header">
|
| 314 |
+
<h1>🤖🚁 Agent2Robot</h1>
|
| 315 |
+
<h2>LLM-Agent-Designed Obstacle-Passing Vehicle System</h2>
|
| 316 |
+
<p><strong>Hackathon Submission - Track 3: Agentic Demo Showcase</strong></p>
|
| 317 |
+
<p>Describe your desired vehicle and task in natural language, then watch our AI agent design, simulate, and optimize it in real-time!</p>
|
| 318 |
+
</div>
|
| 319 |
+
""")
|
| 320 |
+
|
| 321 |
+
# Main Input Section
|
| 322 |
+
with gr.Row():
|
| 323 |
+
with gr.Column(scale=1):
|
| 324 |
+
gr.Markdown("## 🎯 1. Define Your Vehicle Challenge")
|
| 325 |
+
|
| 326 |
+
vehicle_type_input = gr.Radio(
|
| 327 |
+
choices=["Robot", "Drone"],
|
| 328 |
+
label="1. Choose Vehicle Type",
|
| 329 |
+
value="Robot",
|
| 330 |
+
info="Select whether you want a ground robot or flying drone"
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
user_description_input = gr.Textbox(
|
| 334 |
+
lines=5,
|
| 335 |
+
label="2. Describe Vehicle's Task & Success Criteria",
|
| 336 |
+
placeholder="e.g., 'Design a robot that can cross the 5cm box obstacle quickly and without tipping over, then stop safely.' or 'Create a drone that flies over the wall, lands gently 1 meter beyond it, and remains stable.'",
|
| 337 |
+
value="Design a robot that can cross the 5cm high obstacle smoothly and come to a controlled stop."
|
| 338 |
+
)
|
| 339 |
+
|
| 340 |
+
start_button = gr.Button(
|
| 341 |
+
"🚀 Start AI Design Process",
|
| 342 |
+
variant="primary",
|
| 343 |
+
size="lg"
|
| 344 |
+
)
|
| 345 |
+
|
| 346 |
+
gr.Markdown("""
|
| 347 |
+
### 📋 Environment Info
|
| 348 |
+
- **Obstacle**: 5cm high × 50cm wide box
|
| 349 |
+
- **Success Target**: Vehicle reaches x > 0.8m
|
| 350 |
+
- **Physics**: Real-time PyBullet simulation
|
| 351 |
+
- **Max Iterations**: 5 design attempts
|
| 352 |
+
""")
|
| 353 |
+
|
| 354 |
+
with gr.Column(scale=2):
|
| 355 |
+
gr.Markdown("## 🤖 2. Watch the AI Agent Work")
|
| 356 |
+
|
| 357 |
+
process_log_output = gr.Textbox(
|
| 358 |
+
label="🤖 AI Agent - Live Process Log",
|
| 359 |
+
lines=15,
|
| 360 |
+
interactive=False,
|
| 361 |
+
show_copy_button=True,
|
| 362 |
+
elem_classes=["process-log"],
|
| 363 |
+
placeholder="Process log will appear here in real-time as the AI agent works...",
|
| 364 |
+
value=""
|
| 365 |
+
)
|
| 366 |
+
|
| 367 |
+
with gr.Row():
|
| 368 |
+
current_design_specs_output = gr.JSON(
|
| 369 |
+
label="⚙️ Current Design Specs Being Tested",
|
| 370 |
+
value={}
|
| 371 |
+
)
|
| 372 |
+
|
| 373 |
+
progress_bar_output = gr.Slider(
|
| 374 |
+
minimum=0,
|
| 375 |
+
maximum=100,
|
| 376 |
+
step=1,
|
| 377 |
+
label="Progress (%)",
|
| 378 |
+
interactive=False,
|
| 379 |
+
show_label=True,
|
| 380 |
+
value=0
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
# Results Section
|
| 384 |
+
with gr.Accordion("🏆 Final Results & Design Specifications", open=True) as results_accordion:
|
| 385 |
+
final_status_output = gr.Markdown(
|
| 386 |
+
label="🏁 Final Run Status",
|
| 387 |
+
value="Waiting for process to complete..."
|
| 388 |
+
)
|
| 389 |
+
|
| 390 |
+
with gr.Row():
|
| 391 |
+
with gr.Column(scale=2):
|
| 392 |
+
simulation_video_output = gr.Image(
|
| 393 |
+
label="🎬 Simulation of Best Design's Trial",
|
| 394 |
+
interactive=False,
|
| 395 |
+
height=300,
|
| 396 |
+
value=None
|
| 397 |
+
)
|
| 398 |
+
|
| 399 |
+
performance_summary_output = gr.Markdown(
|
| 400 |
+
label="📊 Performance Summary of Best Design",
|
| 401 |
+
value=""
|
| 402 |
+
)
|
| 403 |
+
|
| 404 |
+
with gr.Column(scale=1):
|
| 405 |
+
best_design_specs_output = gr.JSON(
|
| 406 |
+
label="🔩 Best Vehicle Design Specifications",
|
| 407 |
+
show_label=True,
|
| 408 |
+
value={}
|
| 409 |
+
)
|
| 410 |
+
|
| 411 |
+
download_json_output = gr.File(
|
| 412 |
+
label="📄 Download Best Design Specs (JSON)",
|
| 413 |
+
file_count="single",
|
| 414 |
+
type="filepath",
|
| 415 |
+
interactive=True,
|
| 416 |
+
value=None
|
| 417 |
+
)
|
| 418 |
+
|
| 419 |
+
llm_rationale_output = gr.Textbox(
|
| 420 |
+
label="💡 LLM's Design Rationale",
|
| 421 |
+
lines=6,
|
| 422 |
+
interactive=False,
|
| 423 |
+
show_copy_button=True,
|
| 424 |
+
value=""
|
| 425 |
+
)
|
| 426 |
+
|
| 427 |
+
# Connect button to the wrapper function
|
| 428 |
+
start_button.click(
|
| 429 |
+
fn=ui_function_wrapper,
|
| 430 |
+
inputs=[vehicle_type_input, user_description_input],
|
| 431 |
+
outputs=[
|
| 432 |
+
process_log_output,
|
| 433 |
+
current_design_specs_output,
|
| 434 |
+
progress_bar_output,
|
| 435 |
+
final_status_output,
|
| 436 |
+
simulation_video_output,
|
| 437 |
+
best_design_specs_output,
|
| 438 |
+
download_json_output,
|
| 439 |
+
performance_summary_output,
|
| 440 |
+
llm_rationale_output
|
| 441 |
+
],
|
| 442 |
+
show_progress=False # We handle progress manually
|
| 443 |
+
)
|
| 444 |
+
|
| 445 |
+
# Information Footer
|
| 446 |
+
gr.Markdown("---")
|
| 447 |
+
gr.Markdown("""
|
| 448 |
+
## 🔬 How the Agentic AI Works
|
| 449 |
+
|
| 450 |
+
1. **🎯 Criteria Interpretation**: AI analyzes your natural language task and defines measurable success conditions
|
| 451 |
+
2. **🔧 Intelligent Design**: LLM proposes vehicle specifications based on physics principles and your requirements
|
| 452 |
+
3. **⚗️ Physics Simulation**: Each design is tested in accurate PyBullet physics simulation with real obstacles
|
| 453 |
+
4. **📊 Performance Analysis**: Results are evaluated against your interpreted criteria with detailed metrics
|
| 454 |
+
5. **🔄 Iterative Learning**: AI uses simulation feedback to refine and improve designs automatically
|
| 455 |
+
6. **🏆 Best Design Selection**: System tracks performance and presents the optimal solution found
|
| 456 |
+
|
| 457 |
+
**🚀 Innovation**: This demonstrates autonomous AI that goes beyond text generation - it's an agent that designs, tests, learns, and optimizes physical systems to meet user-defined functional requirements.
|
| 458 |
+
""")
|
| 459 |
+
|
| 460 |
+
return demo
|
| 461 |
+
|
| 462 |
+
if __name__ == "__main__":
|
| 463 |
+
print("🤖🚁 Agent2Robot - LLM-Agent-Designed Vehicle System")
|
| 464 |
+
print("=" * 60)
|
| 465 |
+
print("🚀 Launching enhanced Gradio interface...")
|
| 466 |
+
|
| 467 |
+
try:
|
| 468 |
+
# Create and launch the interface
|
| 469 |
+
app = create_agent2robot_interface()
|
| 470 |
+
app.launch(
|
| 471 |
+
server_name="0.0.0.0",
|
| 472 |
+
server_port=7860,
|
| 473 |
+
share=False, # Set to True for public sharing
|
| 474 |
+
show_error=True,
|
| 475 |
+
inbrowser=True,
|
| 476 |
+
quiet=False
|
| 477 |
+
)
|
| 478 |
+
except Exception as e:
|
| 479 |
+
print(f"❌ Error launching app: {e}")
|
| 480 |
+
print("Please check your installation and try again.")
|
requirements.txt
CHANGED
|
@@ -1,15 +1,15 @@
|
|
| 1 |
-
|
| 2 |
gradio>=4.44.1
|
| 3 |
-
imageio>=2.20.0
|
| 4 |
# transformers>=4.21.0
|
| 5 |
# torch>=1.12.0
|
| 6 |
-
Pillow>=9.0.0
|
| 7 |
-
numpy>=1.21.0
|
| 8 |
-
requests>=2.28.0
|
| 9 |
-
certifi>=2022.0.0
|
| 10 |
-
mcp>=1.0.0
|
| 11 |
-
fastapi>=0.100.0
|
| 12 |
-
uvicorn>=0.20.0
|
| 13 |
-
scipy>=1.9.0
|
| 14 |
-
matplotlib>=3.5.0
|
| 15 |
-
imageio-ffmpeg>=0.4.7
|
|
|
|
| 1 |
+
# Minimal requirements for Phase 1 debugging
|
| 2 |
gradio>=4.44.1
|
| 3 |
+
# imageio>=2.20.0
|
| 4 |
# transformers>=4.21.0
|
| 5 |
# torch>=1.12.0
|
| 6 |
+
# Pillow>=9.0.0
|
| 7 |
+
# numpy>=1.21.0
|
| 8 |
+
# requests>=2.28.0
|
| 9 |
+
# certifi>=2022.0.0
|
| 10 |
+
# mcp>=1.0.0
|
| 11 |
+
# fastapi>=0.100.0
|
| 12 |
+
# uvicorn>=0.20.0
|
| 13 |
+
# scipy>=1.9.0
|
| 14 |
+
# matplotlib>=3.5.0
|
| 15 |
+
# imageio-ffmpeg>=0.4.7
|