File size: 6,802 Bytes
46074e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/usr/bin/env python3
"""
Hackathon Demo Launcher
LLM-Agent-Designed Obstacle-Passing Vehicle System
Track 3: Agentic Demo Showcase
"""

import sys
import os
import ssl

# SSL workaround for Gradio/network issues
try:
    import certifi
    os.environ['SSL_CERT_FILE'] = certifi.where()
except ImportError:
    pass

# Try to disable SSL verification as a workaround
try:
    ssl._create_default_https_context = ssl._create_unverified_context
except AttributeError:
    pass

import webbrowser
import time

def print_banner():
    """Print the hackathon banner"""
    print("=" * 80)
    print("πŸ€–πŸš LLM-AGENT-DESIGNED VEHICLE SYSTEM - HACKATHON DEMO")
    print("          TRACK 3: AGENTIC DEMO SHOWCASE")
    print("=" * 80)
    print()

def check_dependencies():
    """Check if all required dependencies are installed"""
    print("πŸ” Checking dependencies...")
    
    missing_deps = []
    
    # Check for required packages
    required_packages = [
        ('gradio', 'gradio'),
        ('pybullet', 'pybullet'),
        ('transformers', 'transformers'),
        ('torch', 'torch'),
        ('Pillow', 'PIL'),
        ('imageio', 'imageio'),
        ('numpy', 'numpy')
    ]
    
    for package_name, import_name in required_packages:
        try:
            __import__(import_name)
            print(f"  βœ… {package_name}")
        except ImportError:
            print(f"  ❌ {package_name} - MISSING")
            missing_deps.append(package_name)
        except Exception as e:
            print(f"  ⚠️  {package_name} - Import warning: {str(e)[:50]}...")
    
    if missing_deps:
        print(f"\n⚠️  Missing dependencies: {', '.join(missing_deps)}")
        print("Please install them using:")
        print("   pip install -r requirements.txt")
        return False
    
    print("βœ… All dependencies are available!")
    return True

def show_options():
    """Show available demo options"""
    print("\n🎯 HACKATHON DEMO OPTIONS:")
    print()
    print("1. 🌐 Interactive Gradio Web Interface (Recommended)")
    print("   - Full agentic demo with real-time feedback")
    print("   - Visual simulation results")
    print("   - Downloadable design specifications")
    print()
    print("2. πŸ–₯️  System Demonstration & Feature Overview")
    print("   - Comprehensive feature walkthrough")
    print("   - Technical implementation details")
    print("   - Hackathon judging criteria alignment")
    print()
    print("3. πŸ“š Documentation & README Preview")
    print("   - View generated README content")
    print("   - Submission materials overview")
    print()

def launch_gradio_demo():
    """Launch the main Gradio interface"""
    print("πŸš€ Launching Interactive Gradio Demo...")
    print("This will start the web interface where you can:")
    print("  β€’ Select vehicle type (robot/drone)")
    print("  β€’ Describe your design task in natural language")
    print("  β€’ Watch the LLM agent work in real-time")
    print("  β€’ See physics simulation results")
    print("  β€’ Download design specifications")
    print()
    
    try:
        from main_orchestrator import create_hackathon_gradio_interface
        
        print("Creating interface...")
        interface = create_hackathon_gradio_interface()
        
        print("βœ… Interface created successfully!")
        print()
        print("🌐 Starting web server...")
        print("πŸ“‹ The demo will open in your browser automatically")
        print("πŸ”— URL: http://localhost:7860")
        print()
        print("πŸ’‘ TIP: Try these example tasks:")
        print("  β€’ 'Design a robot that crosses quickly and stops safely'")
        print("  β€’ 'Create a drone that flies over and lands gently'")
        print("  β€’ 'Build a stable robot for rough terrain'")
        print()
        print("⚠️  Press Ctrl+C to stop the server")
        print()
        
        # Launch with browser opening
        interface.launch(
            server_name="0.0.0.0",
            server_port=7860,
            share=False,  # Set to True for public sharing
            show_error=True,
            inbrowser=True,
            quiet=False
        )
        
    except Exception as e:
        print(f"❌ Error launching Gradio demo: {e}")
        print("Please check your installation and try again.")
        return False
    
    return True

def run_system_demo():
    """Run the comprehensive system demonstration"""
    print("πŸ–₯️  Running System Demonstration...")
    print()
    
    try:
        from hackathon_demo import main
        main()
    except Exception as e:
        print(f"❌ Error running system demo: {e}")
        return False
    
    return True

def show_readme():
    """Display README content"""
    print("πŸ“š README & Documentation Preview...")
    print()
    
    try:
        with open('README.md', 'r', encoding='utf-8') as f:
            content = f.read()
        
        # Show first part of README
        lines = content.split('\n')
        preview_lines = lines[:50]  # Show first 50 lines
        
        for line in preview_lines:
            print(line)
        
        if len(lines) > 50:
            print("\n... (README continues - see README.md for full content)")
        
        print(f"\nπŸ“„ Full README available in: README.md")
        print(f"πŸ“Š Total README length: {len(lines)} lines")
        
    except Exception as e:
        print(f"❌ Error reading README: {e}")
        return False
    
    return True

def main():
    """Main launcher function"""
    print_banner()
    
    # Check dependencies first
    if not check_dependencies():
        print("\n❌ Cannot proceed without required dependencies.")
        sys.exit(1)
    
    # Show options
    show_options()
    
    while True:
        try:
            print("\n" + "─" * 60)
            choice = input("Enter your choice (1-3, or 'q' to quit): ").strip().lower()
            
            if choice in ['q', 'quit', 'exit']:
                print("πŸ‘‹ Thank you for exploring our hackathon submission!")
                break
            elif choice == '1':
                if launch_gradio_demo():
                    break  # Exit after Gradio demo ends
            elif choice == '2':
                run_system_demo()
            elif choice == '3':
                show_readme()
            else:
                print("❌ Invalid choice. Please enter 1, 2, 3, or 'q'.")
                
        except KeyboardInterrupt:
            print("\n\nπŸ‘‹ Demo interrupted. Thank you for exploring our submission!")
            break
        except Exception as e:
            print(f"\n❌ Unexpected error: {e}")
            print("Please try again or contact the developers.")

if __name__ == "__main__":
    main()