Spaces:
No application file
No application file
sam133
commited on
Commit
·
932f692
1
Parent(s):
1437a84
� PHASE 3
Browse files
app.py
CHANGED
|
@@ -1,30 +1,37 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
Agent2Robot - Phase 2 Step
|
| 4 |
-
Systematic Debugging - Adding gr.
|
| 5 |
"""
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
def dummy_function(vehicle_type, user_description):
|
| 10 |
-
"""Test function with multiple inputs and outputs"""
|
| 11 |
if not user_description:
|
| 12 |
user_description = "No description provided"
|
| 13 |
|
| 14 |
-
# Return multiple outputs for testing
|
| 15 |
text_output = f"Vehicle: {vehicle_type}\nDescription: {user_description}\nTest successful!"
|
| 16 |
json_output = {
|
| 17 |
"vehicle_type": vehicle_type,
|
| 18 |
"description": user_description,
|
| 19 |
"test_status": "success",
|
| 20 |
-
"iteration": 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
}
|
| 22 |
progress_value = 75
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
return text_output, json_output, progress_value
|
| 25 |
|
| 26 |
def create_minimal_app():
|
| 27 |
-
"""Create minimal Gradio interface for testing - Step
|
| 28 |
|
| 29 |
# Custom CSS for better appearance (from original)
|
| 30 |
custom_css = """
|
|
@@ -40,7 +47,7 @@ def create_minimal_app():
|
|
| 40 |
"""
|
| 41 |
|
| 42 |
with gr.Blocks(
|
| 43 |
-
title="🤖🚁 Agent2Robot - Phase 2 Step
|
| 44 |
theme=gr.themes.Soft(),
|
| 45 |
css=custom_css
|
| 46 |
) as demo:
|
|
@@ -49,14 +56,14 @@ def create_minimal_app():
|
|
| 49 |
gr.HTML("""
|
| 50 |
<div class="main-header">
|
| 51 |
<h1>🤖🚁 Agent2Robot</h1>
|
| 52 |
-
<h2>Phase 2 Step
|
| 53 |
-
<p><strong>Adding
|
| 54 |
</div>
|
| 55 |
""")
|
| 56 |
|
| 57 |
# Static Markdown (from original)
|
| 58 |
gr.Markdown("## 🔧 Phase 2: Systematic Component Testing")
|
| 59 |
-
gr.Markdown("**Step
|
| 60 |
|
| 61 |
# Input Components (working from Step 2)
|
| 62 |
with gr.Row():
|
|
@@ -83,17 +90,37 @@ def create_minimal_app():
|
|
| 83 |
size="lg"
|
| 84 |
)
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
gr.Markdown("""
|
| 87 |
### 📋 Environment Info
|
| 88 |
-
- **Test Phase**: Phase 2 Step
|
| 89 |
-
- **Components Added**:
|
| 90 |
-
- **Status**: Testing
|
| 91 |
""")
|
| 92 |
|
| 93 |
with gr.Column(scale=2):
|
| 94 |
gr.Markdown("## 🤖 2. Test Outputs")
|
| 95 |
|
| 96 |
-
# OUTPUT COMPONENTS (from
|
| 97 |
output_textbox = gr.Textbox(
|
| 98 |
label="📝 Text Output",
|
| 99 |
lines=5,
|
|
@@ -102,13 +129,13 @@ def create_minimal_app():
|
|
| 102 |
)
|
| 103 |
|
| 104 |
with gr.Row():
|
| 105 |
-
# Test gr.JSON (
|
| 106 |
current_design_specs_output = gr.JSON(
|
| 107 |
label="⚙️ JSON Output Test",
|
| 108 |
value={}
|
| 109 |
)
|
| 110 |
|
| 111 |
-
# Test gr.Slider (
|
| 112 |
progress_bar_output = gr.Slider(
|
| 113 |
minimum=0,
|
| 114 |
maximum=100,
|
|
@@ -119,7 +146,7 @@ def create_minimal_app():
|
|
| 119 |
value=0
|
| 120 |
)
|
| 121 |
|
| 122 |
-
# Test gr.Image (
|
| 123 |
simulation_video_output = gr.Image(
|
| 124 |
label="🎬 Image Output Test",
|
| 125 |
interactive=False,
|
|
@@ -127,7 +154,7 @@ def create_minimal_app():
|
|
| 127 |
value=None
|
| 128 |
)
|
| 129 |
|
| 130 |
-
# Test gr.File (
|
| 131 |
download_json_output = gr.File(
|
| 132 |
label="📄 File Output Test",
|
| 133 |
file_count="single",
|
|
@@ -135,23 +162,52 @@ def create_minimal_app():
|
|
| 135 |
interactive=True,
|
| 136 |
value=None
|
| 137 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
-
# Connect button to test function with
|
| 140 |
start_button.click(
|
| 141 |
fn=dummy_function,
|
| 142 |
inputs=[vehicle_type_input, user_description_input],
|
| 143 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
)
|
| 145 |
|
| 146 |
gr.Markdown("---")
|
| 147 |
-
gr.Markdown("**Status**: If
|
| 148 |
|
| 149 |
return demo
|
| 150 |
|
| 151 |
if __name__ == "__main__":
|
| 152 |
-
print("🔧 Agent2Robot - Phase 2 Step
|
| 153 |
print("=" * 50)
|
| 154 |
-
print("🚀 Testing
|
| 155 |
|
| 156 |
try:
|
| 157 |
app = create_minimal_app()
|
|
@@ -165,4 +221,4 @@ if __name__ == "__main__":
|
|
| 165 |
)
|
| 166 |
except Exception as e:
|
| 167 |
print(f"❌ Error launching app: {e}")
|
| 168 |
-
print("
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Agent2Robot - Phase 2 Step 4: Adding Complex Layout Components
|
| 4 |
+
Systematic Debugging - Adding gr.Accordion, complex layouts, multiple yields
|
| 5 |
"""
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
|
| 9 |
def dummy_function(vehicle_type, user_description):
|
| 10 |
+
"""Test function with multiple inputs and outputs - now with more complexity"""
|
| 11 |
if not user_description:
|
| 12 |
user_description = "No description provided"
|
| 13 |
|
| 14 |
+
# Return multiple outputs for testing (matching original function signature)
|
| 15 |
text_output = f"Vehicle: {vehicle_type}\nDescription: {user_description}\nTest successful!"
|
| 16 |
json_output = {
|
| 17 |
"vehicle_type": vehicle_type,
|
| 18 |
"description": user_description,
|
| 19 |
"test_status": "success",
|
| 20 |
+
"iteration": 1,
|
| 21 |
+
"parameters": {
|
| 22 |
+
"speed": 5.2,
|
| 23 |
+
"weight": 1.8,
|
| 24 |
+
"dimensions": [10, 8, 6]
|
| 25 |
+
}
|
| 26 |
}
|
| 27 |
progress_value = 75
|
| 28 |
+
image_output = None # Placeholder for image
|
| 29 |
+
file_output = None # Placeholder for file
|
| 30 |
|
| 31 |
+
return text_output, json_output, progress_value, image_output, file_output
|
| 32 |
|
| 33 |
def create_minimal_app():
|
| 34 |
+
"""Create minimal Gradio interface for testing - Step 4: Complex Layout Components"""
|
| 35 |
|
| 36 |
# Custom CSS for better appearance (from original)
|
| 37 |
custom_css = """
|
|
|
|
| 47 |
"""
|
| 48 |
|
| 49 |
with gr.Blocks(
|
| 50 |
+
title="🤖🚁 Agent2Robot - Phase 2 Step 4",
|
| 51 |
theme=gr.themes.Soft(),
|
| 52 |
css=custom_css
|
| 53 |
) as demo:
|
|
|
|
| 56 |
gr.HTML("""
|
| 57 |
<div class="main-header">
|
| 58 |
<h1>🤖🚁 Agent2Robot</h1>
|
| 59 |
+
<h2>Phase 2 Step 4: Complex Layout Components Test</h2>
|
| 60 |
+
<p><strong>Adding gr.Accordion, complex layouts, multiple outputs</strong></p>
|
| 61 |
</div>
|
| 62 |
""")
|
| 63 |
|
| 64 |
# Static Markdown (from original)
|
| 65 |
gr.Markdown("## 🔧 Phase 2: Systematic Component Testing")
|
| 66 |
+
gr.Markdown("**Step 4**: Testing complex layout components (Accordion, complex structures)")
|
| 67 |
|
| 68 |
# Input Components (working from Step 2)
|
| 69 |
with gr.Row():
|
|
|
|
| 90 |
size="lg"
|
| 91 |
)
|
| 92 |
|
| 93 |
+
# TEST: Add gr.Accordion (HIGHLY SUSPECT for schema issues)
|
| 94 |
+
with gr.Accordion("📋 Advanced Options", open=False):
|
| 95 |
+
gr.Markdown("""
|
| 96 |
+
### 🔧 Test Accordion Component
|
| 97 |
+
This collapsible section tests gr.Accordion which may cause schema issues.
|
| 98 |
+
""")
|
| 99 |
+
|
| 100 |
+
test_slider = gr.Slider(
|
| 101 |
+
minimum=0,
|
| 102 |
+
maximum=10,
|
| 103 |
+
step=0.1,
|
| 104 |
+
value=5.0,
|
| 105 |
+
label="Test Parameter"
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
test_checkbox = gr.Checkbox(
|
| 109 |
+
label="Enable Advanced Mode",
|
| 110 |
+
value=False
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
gr.Markdown("""
|
| 114 |
### 📋 Environment Info
|
| 115 |
+
- **Test Phase**: Phase 2 Step 4
|
| 116 |
+
- **Components Added**: gr.Accordion, complex layouts, multiple outputs
|
| 117 |
+
- **Status**: Testing complex layout components
|
| 118 |
""")
|
| 119 |
|
| 120 |
with gr.Column(scale=2):
|
| 121 |
gr.Markdown("## 🤖 2. Test Outputs")
|
| 122 |
|
| 123 |
+
# OUTPUT COMPONENTS (working from Step 3)
|
| 124 |
output_textbox = gr.Textbox(
|
| 125 |
label="📝 Text Output",
|
| 126 |
lines=5,
|
|
|
|
| 129 |
)
|
| 130 |
|
| 131 |
with gr.Row():
|
| 132 |
+
# Test gr.JSON (working from Step 3)
|
| 133 |
current_design_specs_output = gr.JSON(
|
| 134 |
label="⚙️ JSON Output Test",
|
| 135 |
value={}
|
| 136 |
)
|
| 137 |
|
| 138 |
+
# Test gr.Slider (working from Step 3)
|
| 139 |
progress_bar_output = gr.Slider(
|
| 140 |
minimum=0,
|
| 141 |
maximum=100,
|
|
|
|
| 146 |
value=0
|
| 147 |
)
|
| 148 |
|
| 149 |
+
# Test gr.Image (working from Step 3)
|
| 150 |
simulation_video_output = gr.Image(
|
| 151 |
label="🎬 Image Output Test",
|
| 152 |
interactive=False,
|
|
|
|
| 154 |
value=None
|
| 155 |
)
|
| 156 |
|
| 157 |
+
# Test gr.File (working from Step 3)
|
| 158 |
download_json_output = gr.File(
|
| 159 |
label="📄 File Output Test",
|
| 160 |
file_count="single",
|
|
|
|
| 162 |
interactive=True,
|
| 163 |
value=None
|
| 164 |
)
|
| 165 |
+
|
| 166 |
+
# TEST: Add ANOTHER gr.Accordion for output section (TESTING MULTIPLE ACCORDIONS)
|
| 167 |
+
with gr.Accordion("📊 Detailed Results", open=True):
|
| 168 |
+
gr.Markdown("### 🔍 Advanced Output Analysis")
|
| 169 |
+
|
| 170 |
+
detailed_output = gr.Textbox(
|
| 171 |
+
label="Detailed Analysis",
|
| 172 |
+
lines=3,
|
| 173 |
+
value="Detailed results will appear here...",
|
| 174 |
+
interactive=False
|
| 175 |
+
)
|
| 176 |
+
|
| 177 |
+
with gr.Row():
|
| 178 |
+
metrics_json = gr.JSON(
|
| 179 |
+
label="📈 Metrics",
|
| 180 |
+
value={"score": 0, "efficiency": 0}
|
| 181 |
+
)
|
| 182 |
+
|
| 183 |
+
status_text = gr.Textbox(
|
| 184 |
+
label="Status",
|
| 185 |
+
value="Ready",
|
| 186 |
+
interactive=False
|
| 187 |
+
)
|
| 188 |
|
| 189 |
+
# Connect button to test function with ALL outputs (5 outputs now)
|
| 190 |
start_button.click(
|
| 191 |
fn=dummy_function,
|
| 192 |
inputs=[vehicle_type_input, user_description_input],
|
| 193 |
+
outputs=[
|
| 194 |
+
output_textbox,
|
| 195 |
+
current_design_specs_output,
|
| 196 |
+
progress_bar_output,
|
| 197 |
+
simulation_video_output,
|
| 198 |
+
download_json_output
|
| 199 |
+
]
|
| 200 |
)
|
| 201 |
|
| 202 |
gr.Markdown("---")
|
| 203 |
+
gr.Markdown("**Status**: If complex layout components work, the issue is in the original function logic or specific component configurations.")
|
| 204 |
|
| 205 |
return demo
|
| 206 |
|
| 207 |
if __name__ == "__main__":
|
| 208 |
+
print("🔧 Agent2Robot - Phase 2 Step 4")
|
| 209 |
print("=" * 50)
|
| 210 |
+
print("🚀 Testing complex layout components...")
|
| 211 |
|
| 212 |
try:
|
| 213 |
app = create_minimal_app()
|
|
|
|
| 221 |
)
|
| 222 |
except Exception as e:
|
| 223 |
print(f"❌ Error launching app: {e}")
|
| 224 |
+
print("Complex layout components are causing issues.")
|