Spaces:
No application file
No application file
sam133 commited on
Commit ·
1437a84
1
Parent(s): 44090ce
� PHASE 2
Browse files
app.py
CHANGED
|
@@ -1,19 +1,30 @@
|
|
| 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"""
|
| 11 |
if not user_description:
|
| 12 |
user_description = "No description provided"
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def create_minimal_app():
|
| 16 |
-
"""Create minimal Gradio interface for testing - Step
|
| 17 |
|
| 18 |
# Custom CSS for better appearance (from original)
|
| 19 |
custom_css = """
|
|
@@ -29,7 +40,7 @@ def create_minimal_app():
|
|
| 29 |
"""
|
| 30 |
|
| 31 |
with gr.Blocks(
|
| 32 |
-
title="🤖🚁 Agent2Robot - Phase 2 Step
|
| 33 |
theme=gr.themes.Soft(),
|
| 34 |
css=custom_css
|
| 35 |
) as demo:
|
|
@@ -38,16 +49,16 @@ def create_minimal_app():
|
|
| 38 |
gr.HTML("""
|
| 39 |
<div class="main-header">
|
| 40 |
<h1>🤖🚁 Agent2Robot</h1>
|
| 41 |
-
<h2>Phase 2 Step
|
| 42 |
-
<p><strong>Adding back gr.
|
| 43 |
</div>
|
| 44 |
""")
|
| 45 |
|
| 46 |
# Static Markdown (from original)
|
| 47 |
gr.Markdown("## 🔧 Phase 2: Systematic Component Testing")
|
| 48 |
-
gr.Markdown("**Step
|
| 49 |
|
| 50 |
-
#
|
| 51 |
with gr.Row():
|
| 52 |
with gr.Column(scale=1):
|
| 53 |
gr.Markdown("## 🎯 1. Define Your Vehicle Challenge")
|
|
@@ -62,7 +73,7 @@ def create_minimal_app():
|
|
| 62 |
user_description_input = gr.Textbox(
|
| 63 |
lines=5,
|
| 64 |
label="2. Describe Vehicle's Task & Success Criteria",
|
| 65 |
-
placeholder="e.g., 'Design a robot that can cross the 5cm box obstacle quickly and without tipping over, then stop safely.'
|
| 66 |
value="Design a robot that can cross the 5cm high obstacle smoothly and come to a controlled stop."
|
| 67 |
)
|
| 68 |
|
|
@@ -74,37 +85,73 @@ def create_minimal_app():
|
|
| 74 |
|
| 75 |
gr.Markdown("""
|
| 76 |
### 📋 Environment Info
|
| 77 |
-
- **Test Phase**: Phase 2 Step
|
| 78 |
-
- **Components Added**:
|
| 79 |
-
- **Status**: Testing
|
| 80 |
""")
|
| 81 |
|
| 82 |
with gr.Column(scale=2):
|
| 83 |
-
gr.Markdown("## 🤖 2. Test
|
| 84 |
|
|
|
|
| 85 |
output_textbox = gr.Textbox(
|
| 86 |
-
label="
|
| 87 |
-
lines=
|
| 88 |
value="",
|
| 89 |
interactive=False
|
| 90 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
# Connect button to test function
|
| 93 |
start_button.click(
|
| 94 |
fn=dummy_function,
|
| 95 |
inputs=[vehicle_type_input, user_description_input],
|
| 96 |
-
outputs=output_textbox
|
| 97 |
)
|
| 98 |
|
| 99 |
gr.Markdown("---")
|
| 100 |
-
gr.Markdown("**Status**: If
|
| 101 |
|
| 102 |
return demo
|
| 103 |
|
| 104 |
if __name__ == "__main__":
|
| 105 |
-
print("🔧 Agent2Robot - Phase 2 Step
|
| 106 |
print("=" * 50)
|
| 107 |
-
print("🚀 Testing
|
| 108 |
|
| 109 |
try:
|
| 110 |
app = create_minimal_app()
|
|
@@ -118,4 +165,4 @@ if __name__ == "__main__":
|
|
| 118 |
)
|
| 119 |
except Exception as e:
|
| 120 |
print(f"❌ Error launching app: {e}")
|
| 121 |
-
print("
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
Agent2Robot - Phase 2 Step 3: Adding Output Components
|
| 4 |
+
Systematic Debugging - Adding gr.Slider, gr.JSON, gr.Image, gr.File
|
| 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 3: Output Components"""
|
| 28 |
|
| 29 |
# Custom CSS for better appearance (from original)
|
| 30 |
custom_css = """
|
|
|
|
| 40 |
"""
|
| 41 |
|
| 42 |
with gr.Blocks(
|
| 43 |
+
title="🤖🚁 Agent2Robot - Phase 2 Step 3",
|
| 44 |
theme=gr.themes.Soft(),
|
| 45 |
css=custom_css
|
| 46 |
) as demo:
|
|
|
|
| 49 |
gr.HTML("""
|
| 50 |
<div class="main-header">
|
| 51 |
<h1>🤖🚁 Agent2Robot</h1>
|
| 52 |
+
<h2>Phase 2 Step 3: Output Components Test</h2>
|
| 53 |
+
<p><strong>Adding back gr.Slider, gr.JSON, gr.Image, gr.File</strong></p>
|
| 54 |
</div>
|
| 55 |
""")
|
| 56 |
|
| 57 |
# Static Markdown (from original)
|
| 58 |
gr.Markdown("## 🔧 Phase 2: Systematic Component Testing")
|
| 59 |
+
gr.Markdown("**Step 3**: Testing output components (Slider, JSON, Image, File)")
|
| 60 |
|
| 61 |
+
# Input Components (working from Step 2)
|
| 62 |
with gr.Row():
|
| 63 |
with gr.Column(scale=1):
|
| 64 |
gr.Markdown("## 🎯 1. Define Your Vehicle Challenge")
|
|
|
|
| 73 |
user_description_input = gr.Textbox(
|
| 74 |
lines=5,
|
| 75 |
label="2. Describe Vehicle's Task & Success Criteria",
|
| 76 |
+
placeholder="e.g., 'Design a robot that can cross the 5cm box obstacle quickly and without tipping over, then stop safely.'",
|
| 77 |
value="Design a robot that can cross the 5cm high obstacle smoothly and come to a controlled stop."
|
| 78 |
)
|
| 79 |
|
|
|
|
| 85 |
|
| 86 |
gr.Markdown("""
|
| 87 |
### 📋 Environment Info
|
| 88 |
+
- **Test Phase**: Phase 2 Step 3
|
| 89 |
+
- **Components Added**: Output components (Slider, JSON, Image, File)
|
| 90 |
+
- **Status**: Testing output components
|
| 91 |
""")
|
| 92 |
|
| 93 |
with gr.Column(scale=2):
|
| 94 |
+
gr.Markdown("## 🤖 2. Test Outputs")
|
| 95 |
|
| 96 |
+
# OUTPUT COMPONENTS (from original - these are suspect)
|
| 97 |
output_textbox = gr.Textbox(
|
| 98 |
+
label="📝 Text Output",
|
| 99 |
+
lines=5,
|
| 100 |
value="",
|
| 101 |
interactive=False
|
| 102 |
)
|
| 103 |
+
|
| 104 |
+
with gr.Row():
|
| 105 |
+
# Test gr.JSON (MOST SUSPECT)
|
| 106 |
+
current_design_specs_output = gr.JSON(
|
| 107 |
+
label="⚙️ JSON Output Test",
|
| 108 |
+
value={}
|
| 109 |
+
)
|
| 110 |
+
|
| 111 |
+
# Test gr.Slider (LESS SUSPECT)
|
| 112 |
+
progress_bar_output = gr.Slider(
|
| 113 |
+
minimum=0,
|
| 114 |
+
maximum=100,
|
| 115 |
+
step=1,
|
| 116 |
+
label="Progress (%)",
|
| 117 |
+
interactive=False,
|
| 118 |
+
show_label=True,
|
| 119 |
+
value=0
|
| 120 |
+
)
|
| 121 |
+
|
| 122 |
+
# Test gr.Image (SUSPECT)
|
| 123 |
+
simulation_video_output = gr.Image(
|
| 124 |
+
label="🎬 Image Output Test",
|
| 125 |
+
interactive=False,
|
| 126 |
+
height=200,
|
| 127 |
+
value=None
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
# Test gr.File (SUSPECT)
|
| 131 |
+
download_json_output = gr.File(
|
| 132 |
+
label="📄 File Output Test",
|
| 133 |
+
file_count="single",
|
| 134 |
+
type="filepath",
|
| 135 |
+
interactive=True,
|
| 136 |
+
value=None
|
| 137 |
+
)
|
| 138 |
|
| 139 |
+
# Connect button to test function with multiple outputs
|
| 140 |
start_button.click(
|
| 141 |
fn=dummy_function,
|
| 142 |
inputs=[vehicle_type_input, user_description_input],
|
| 143 |
+
outputs=[output_textbox, current_design_specs_output, progress_bar_output]
|
| 144 |
)
|
| 145 |
|
| 146 |
gr.Markdown("---")
|
| 147 |
+
gr.Markdown("**Status**: If output components work without errors, the issue is likely in complex layouts or function logic.")
|
| 148 |
|
| 149 |
return demo
|
| 150 |
|
| 151 |
if __name__ == "__main__":
|
| 152 |
+
print("🔧 Agent2Robot - Phase 2 Step 3")
|
| 153 |
print("=" * 50)
|
| 154 |
+
print("🚀 Testing output components...")
|
| 155 |
|
| 156 |
try:
|
| 157 |
app = create_minimal_app()
|
|
|
|
| 165 |
)
|
| 166 |
except Exception as e:
|
| 167 |
print(f"❌ Error launching app: {e}")
|
| 168 |
+
print("Output components are causing issues.")
|