File size: 7,823 Bytes
46074e2
 
ee969dd
 
46074e2
 
0fe9c4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ca1c22f
46074e2
ee969dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11fe717
ee969dd
46074e2
ee969dd
 
fbfc887
ee969dd
fbfc887
 
 
 
 
 
 
 
 
 
 
 
 
ee969dd
fbfc887
 
 
 
ee969dd
fbfc887
 
ee969dd
 
 
fbfc887
 
46074e2
ee969dd
 
 
46074e2
44090ce
 
 
ee969dd
44090ce
 
 
 
 
46074e2
44090ce
 
 
 
1437a84
44090ce
 
 
 
 
 
 
 
 
 
ee969dd
 
 
 
44090ce
46074e2
44090ce
ee969dd
44090ce
ee969dd
 
 
 
 
 
46074e2
1437a84
 
 
ee969dd
1437a84
 
 
 
 
 
 
 
 
 
 
 
 
ee969dd
 
 
 
 
 
 
 
 
 
 
 
 
 
46074e2
ee969dd
44090ce
ee969dd
 
932f692
ee969dd
 
932f692
 
ee969dd
11fe717
44090ce
fbfc887
46074e2
ee969dd
46074e2
 
 
 
ee969dd
 
 
46074e2
 
ee969dd
0fe9c4b
 
 
46074e2
 
 
0fe9c4b
46074e2
0fe9c4b
 
 
46074e2
 
fbfc887
0fe9c4b
 
 
 
 
 
 
 
 
 
 
 
 
 
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
220
221
#!/usr/bin/env python3
"""
Agent2Robot - MINIMAL WORKING VERSION
Based on successful Step 4 but with simple return function
"""

import os
import ssl

# Multiple SSL fixes for Windows/conda environments
try:
    # Try to fix SSL certificate path
    import certifi
    os.environ['SSL_CERT_FILE'] = certifi.where()
    os.environ['REQUESTS_CA_BUNDLE'] = certifi.where()
except ImportError:
    print("⚠️ Warning: certifi not available, using alternative SSL fix")

# Disable SSL verification if needed (for development only)
ssl._create_default_https_context = ssl._create_unverified_context

# Alternative approach: Set empty SSL_CERT_FILE if the current one is problematic
if 'SSL_CERT_FILE' in os.environ:
    try:
        with open(os.environ['SSL_CERT_FILE'], 'r') as f:
            pass  # Test if file is readable
    except:
        # If the current SSL_CERT_FILE is problematic, try to unset it
        del os.environ['SSL_CERT_FILE']
        try:
            import certifi
            os.environ['SSL_CERT_FILE'] = certifi.where()
        except:
            pass

import gradio as gr

def simple_test_function(vehicle_type, user_description):
    """Simple test function that returns results like Step 4 worked"""
    if not user_description:
        user_description = "No description provided"
    
    # Simple return (like Step 4 but with return instead of yield)
    text_output = f"βœ… COMPLETED!\nVehicle: {vehicle_type}\nDescription: {user_description}\nTest successful!"
    json_output = {
        "vehicle_type": vehicle_type,
        "description": user_description,
        "test_status": "success",
        "parameters": {
            "speed": 5.2,
            "weight": 1.8,
            "dimensions": [10, 8, 6]
        }
    }
    progress_value = 100
    image_output = None
    file_output = None
    
    return text_output, json_output, progress_value, image_output, file_output

def create_minimal_working_app():
    """MINIMAL working app based on successful Step 4"""
    
    # Exact same CSS as Step 4 (worked)
    custom_css = """
    .main-header {
        text-align: center;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        padding: 30px;
        border-radius: 15px;
        margin-bottom: 20px;
        box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    }
    """
    
    with gr.Blocks(
        title="πŸ€–πŸš Agent2Robot - MINIMAL WORKING",
        theme=gr.themes.Soft(),
        css=custom_css
    ) as demo:
        
        # Exact same header as Step 4 (worked)
        gr.HTML("""
        <div class="main-header">
            <h1>πŸ€–πŸš Agent2Robot</h1>
            <h2>MINIMAL WORKING VERSION</h2>
            <p><strong>Based on successful Step 4 components</strong></p>
        </div>
        """)
        
        # Exact same layout as Step 4 (worked)
        gr.Markdown("## πŸ”§ MINIMAL WORKING TEST")
        
        with gr.Row():
            with gr.Column(scale=1):
                gr.Markdown("## 🎯 1. Define Your Vehicle Challenge")
                
                # Exact same components as Step 4 (worked)
                vehicle_type_input = gr.Radio(
                    choices=["Robot", "Drone"], 
                    label="1. Choose Vehicle Type",
                    value="Robot",
                    info="Select whether you want a ground robot or flying drone"
                )
                
                user_description_input = gr.Textbox(
                    lines=5, 
                    label="2. Describe Vehicle's Task & Success Criteria",
                    placeholder="e.g., 'Design a robot that can cross the 5cm box obstacle quickly and without tipping over, then stop safely.'",
                    value="Design a robot that can cross the 5cm high obstacle smoothly and come to a controlled stop."
                )
                
                start_button = gr.Button(
                    "πŸš€ Start AI Design Process", 
                    variant="primary",
                    size="lg"
                )
                
                gr.Markdown("""
                ### πŸ“‹ Status
                - **Version**: Minimal working (Step 4 base)
                - **Function**: Simple return (no yield)
                - **Goal**: Isolate the problematic component
                """)
            
            with gr.Column(scale=2):
                gr.Markdown("## πŸ€– 2. Test Outputs")
                
                # Exact same output components as Step 4 (worked)
                output_textbox = gr.Textbox(
                    label="πŸ“ Text Output",
                    lines=5,
                    value="",
                    interactive=False
                )
                
                with gr.Row():
                    current_design_specs_output = gr.JSON(
                        label="βš™οΈ JSON Output Test",
                        value={}
                    )
                    
                    progress_bar_output = gr.Slider(
                        minimum=0, 
                        maximum=100,
                        step=1,
                        label="Progress (%)",
                        interactive=False,
                        show_label=True,
                        value=0
                    )
                
                simulation_video_output = gr.Image(
                    label="🎬 Image Output Test",
                    interactive=False,
                    height=200,
                    value=None
                )
                
                download_json_output = gr.File(
                    label="πŸ“„ File Output Test",
                    file_count="single",
                    type="filepath",
                    interactive=True,
                    value=None
                )
        
        # Simple button connection (5 outputs like Step 4)
        start_button.click(
            fn=simple_test_function, 
            inputs=[vehicle_type_input, user_description_input], 
            outputs=[
                output_textbox, 
                current_design_specs_output, 
                progress_bar_output,
                simulation_video_output,
                download_json_output
            ]
        )
        
        gr.Markdown("---")
        gr.Markdown("**Status**: If this works, we can add components one by one to find the problematic one.")
    
    return demo

if __name__ == "__main__":
    print("πŸ”§ Agent2Robot - MINIMAL WORKING VERSION")
    print("=" * 50)
    print("πŸš€ Testing minimal working components...")
    
    try:
        app = create_minimal_working_app()
        print("βœ… App created successfully")
        print("🌐 Launching with share=True (since localhost not accessible)...")
        
        app.launch(
            server_name="0.0.0.0",
            server_port=7860,
            share=True,  # Fixed: Set to True since localhost is not accessible
            show_error=True,
            inbrowser=False,  # Changed to False to avoid browser issues
            quiet=False,
            debug=True  # Added debug mode for better error reporting
        )
    except Exception as e:
        print(f"❌ Error launching app: {e}")
        print("Even minimal version has issues!")
        
        # Additional debugging information
        import traceback
        print("\nπŸ” Full error traceback:")
        traceback.print_exc()
        
        # Try alternative launch with minimal options
        print("\nπŸ”„ Trying alternative launch configuration...")
        try:
            app.launch(share=True, debug=True)
        except Exception as e2:
            print(f"❌ Alternative launch also failed: {e2}")
            print("Please check Gradio installation and dependencies.")