Spaces:
No application file
No application file
| #!/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.") |