Spaces:
Sleeping
Sleeping
Upload gradio_interface.py
Browse files- src/gradio_interface.py +41 -10
src/gradio_interface.py
CHANGED
|
@@ -39,35 +39,66 @@ class GradioInterfaceBuilder:
|
|
| 39 |
|
| 40 |
def create_interface(self):
|
| 41 |
"""Create the main Gradio interface"""
|
|
|
|
| 42 |
with gr.Blocks(title="Mercedes E-class ADAS Manual Interface") as demo:
|
|
|
|
| 43 |
gr.Markdown("# π Mercedes E-class ADAS Manual Interface")
|
| 44 |
gr.Markdown("Ask questions, explore knowledge maps, and test your understanding!")
|
| 45 |
|
| 46 |
# Create tabs with proper order: Setup -> Ask Questions -> Knowledge Map -> Test -> Personalized Learning
|
| 47 |
# Ask Questions is set as default selected tab
|
|
|
|
| 48 |
with gr.Tabs(selected=1 if self.user_profiling else 0) as tabs:
|
| 49 |
# Tab 1: Setup (Cold Start/Onboarding) - only shown if user_profiling is available
|
| 50 |
if self.user_profiling:
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# Tab 2: Ask Questions (Default selected tab)
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
# Tab 3: Knowledge Map
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
# Tab 4: Test Your Knowledge
|
| 63 |
-
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# Tab 5: Personalized Learning Path (if available)
|
| 67 |
if self.adaptive_engine:
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
|
|
|
| 71 |
return demo
|
| 72 |
|
| 73 |
def _create_qa_tab(self):
|
|
|
|
| 39 |
|
| 40 |
def create_interface(self):
|
| 41 |
"""Create the main Gradio interface"""
|
| 42 |
+
print(" [1/6] Creating Gradio Blocks container...")
|
| 43 |
with gr.Blocks(title="Mercedes E-class ADAS Manual Interface") as demo:
|
| 44 |
+
print(" [2/6] Adding header markdown...")
|
| 45 |
gr.Markdown("# π Mercedes E-class ADAS Manual Interface")
|
| 46 |
gr.Markdown("Ask questions, explore knowledge maps, and test your understanding!")
|
| 47 |
|
| 48 |
# Create tabs with proper order: Setup -> Ask Questions -> Knowledge Map -> Test -> Personalized Learning
|
| 49 |
# Ask Questions is set as default selected tab
|
| 50 |
+
print(" [3/6] Creating tabs container...")
|
| 51 |
with gr.Tabs(selected=1 if self.user_profiling else 0) as tabs:
|
| 52 |
# Tab 1: Setup (Cold Start/Onboarding) - only shown if user_profiling is available
|
| 53 |
if self.user_profiling:
|
| 54 |
+
print(" [4/6] Creating Setup tab...")
|
| 55 |
+
try:
|
| 56 |
+
with gr.TabItem("Setup"):
|
| 57 |
+
self._create_onboarding_tab()
|
| 58 |
+
print(" [4/6] β
Setup tab created")
|
| 59 |
+
except Exception as e:
|
| 60 |
+
print(f" [4/6] β οΈ Error creating Setup tab: {e}")
|
| 61 |
|
| 62 |
# Tab 2: Ask Questions (Default selected tab)
|
| 63 |
+
print(" [5/6] Creating Ask Questions tab...")
|
| 64 |
+
try:
|
| 65 |
+
with gr.TabItem("Ask Questions"):
|
| 66 |
+
self._create_qa_tab()
|
| 67 |
+
print(" [5/6] β
Ask Questions tab created")
|
| 68 |
+
except Exception as e:
|
| 69 |
+
print(f" [5/6] β οΈ Error creating Ask Questions tab: {e}")
|
| 70 |
+
import traceback
|
| 71 |
+
traceback.print_exc()
|
| 72 |
|
| 73 |
# Tab 3: Knowledge Map
|
| 74 |
+
print(" [6/7] Creating Knowledge Map tab...")
|
| 75 |
+
try:
|
| 76 |
+
with gr.TabItem("Knowledge Map"):
|
| 77 |
+
self._create_knowledge_map_tab()
|
| 78 |
+
print(" [6/7] β
Knowledge Map tab created")
|
| 79 |
+
except Exception as e:
|
| 80 |
+
print(f" [6/7] β οΈ Error creating Knowledge Map tab: {e}")
|
| 81 |
|
| 82 |
# Tab 4: Test Your Knowledge
|
| 83 |
+
print(" [7/8] Creating Test Your Knowledge tab...")
|
| 84 |
+
try:
|
| 85 |
+
with gr.TabItem("Test Your Knowledge"):
|
| 86 |
+
self._create_test_tab()
|
| 87 |
+
print(" [7/8] β
Test Your Knowledge tab created")
|
| 88 |
+
except Exception as e:
|
| 89 |
+
print(f" [7/8] β οΈ Error creating Test Your Knowledge tab: {e}")
|
| 90 |
|
| 91 |
# Tab 5: Personalized Learning Path (if available)
|
| 92 |
if self.adaptive_engine:
|
| 93 |
+
print(" [8/8] Creating Personalized Learning tab...")
|
| 94 |
+
try:
|
| 95 |
+
with gr.TabItem("Personalized Learning"):
|
| 96 |
+
self._create_learning_path_tab()
|
| 97 |
+
print(" [8/8] β
Personalized Learning tab created")
|
| 98 |
+
except Exception as e:
|
| 99 |
+
print(f" [8/8] β οΈ Error creating Personalized Learning tab: {e}")
|
| 100 |
|
| 101 |
+
print(" β
All tabs created, returning demo object")
|
| 102 |
return demo
|
| 103 |
|
| 104 |
def _create_qa_tab(self):
|