Bryceeee commited on
Commit
0cfa3a6
Β·
verified Β·
1 Parent(s): bb12cfa

Upload 17 files

Browse files
app.py CHANGED
@@ -252,22 +252,25 @@ def create_app():
252
 
253
  # Create the app for Hugging Face Spaces
254
  # Spaces will automatically detect Gradio and run this
255
- # Note: Spaces may import the module multiple times, but we only create demo once at module level
256
- try:
257
- print("πŸ”„ Initializing app...")
258
- demo = create_app()
259
- print("βœ… App initialized successfully!")
260
- except Exception as e:
261
- print(f"❌ Error creating app: {e}")
262
- import traceback
263
- traceback.print_exc()
264
- # Create a minimal error interface
265
- import gradio as gr
266
- demo = gr.Interface(
267
- fn=lambda: f"Error: {str(e)}\n\nPlease check the logs for details.",
268
- inputs=None,
269
- outputs=gr.Textbox(),
270
- title="CSRC Car Manual RAG System - Error",
271
- description="An error occurred during initialization. Please check the logs."
272
- )
 
 
 
273
 
 
252
 
253
  # Create the app for Hugging Face Spaces
254
  # Spaces will automatically detect Gradio and run this
255
+ # Use module-level variable to prevent multiple initializations
256
+ if 'demo' not in globals():
257
+ try:
258
+ print("πŸ”„ Initializing app...")
259
+ demo = create_app()
260
+ print("βœ… App initialized successfully!")
261
+ except Exception as e:
262
+ print(f"❌ Error creating app: {e}")
263
+ import traceback
264
+ traceback.print_exc()
265
+ # Create a minimal error interface
266
+ import gradio as gr
267
+ demo = gr.Interface(
268
+ fn=lambda: f"Error: {str(e)}\n\nPlease check the logs for details.",
269
+ inputs=None,
270
+ outputs=gr.Textbox(),
271
+ title="CSRC Car Manual RAG System - Error",
272
+ description="An error occurred during initialization. Please check the logs."
273
+ )
274
+ else:
275
+ print("ℹ️ App already initialized, reusing existing instance")
276
 
src/__init__.py CHANGED
@@ -10,3 +10,4 @@ __version__ = "1.0.0"
10
 
11
 
12
 
 
 
10
 
11
 
12
 
13
+
src/__pycache__/__init__.cpython-312.pyc CHANGED
Binary files a/src/__pycache__/__init__.cpython-312.pyc and b/src/__pycache__/__init__.cpython-312.pyc differ
 
src/__pycache__/config.cpython-312.pyc CHANGED
Binary files a/src/__pycache__/config.cpython-312.pyc and b/src/__pycache__/config.cpython-312.pyc differ
 
src/__pycache__/gradio_interface.cpython-312.pyc CHANGED
Binary files a/src/__pycache__/gradio_interface.cpython-312.pyc and b/src/__pycache__/gradio_interface.cpython-312.pyc differ
 
src/__pycache__/knowledge_graph.cpython-312.pyc CHANGED
Binary files a/src/__pycache__/knowledge_graph.cpython-312.pyc and b/src/__pycache__/knowledge_graph.cpython-312.pyc differ
 
src/__pycache__/question_generator.cpython-312.pyc CHANGED
Binary files a/src/__pycache__/question_generator.cpython-312.pyc and b/src/__pycache__/question_generator.cpython-312.pyc differ
 
src/__pycache__/rag_query.cpython-312.pyc CHANGED
Binary files a/src/__pycache__/rag_query.cpython-312.pyc and b/src/__pycache__/rag_query.cpython-312.pyc differ
 
src/__pycache__/vector_store.cpython-312.pyc CHANGED
Binary files a/src/__pycache__/vector_store.cpython-312.pyc and b/src/__pycache__/vector_store.cpython-312.pyc differ
 
src/evaluation.py CHANGED
@@ -224,3 +224,4 @@ Generated on: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
224
 
225
 
226
 
 
 
224
 
225
 
226
 
227
+
src/gradio_interface.py CHANGED
@@ -60,7 +60,17 @@ class GradioInterfaceBuilder:
60
  # Create tabs with proper order: Setup -> Ask Questions -> Knowledge Map -> Test -> Personalized Learning
61
  # Ask Questions is set as default selected tab
62
  # Gradio 6.0 compatibility: Use Tab (which is gr.Tab for 6.0, gr.TabItem for 4.x)
63
- with gr.Tabs(selected=1 if self.user_profiling else 0) as tabs:
 
 
 
 
 
 
 
 
 
 
64
  # Tab 1: Setup (Cold Start/Onboarding) - only shown if user_profiling is available
65
  if self.user_profiling:
66
  with Tab("Setup"):
 
60
  # Create tabs with proper order: Setup -> Ask Questions -> Knowledge Map -> Test -> Personalized Learning
61
  # Ask Questions is set as default selected tab
62
  # Gradio 6.0 compatibility: Use Tab (which is gr.Tab for 6.0, gr.TabItem for 4.x)
63
+ # Note: In Gradio 6.0, selected parameter might be deprecated, try both ways
64
+ def create_tabs():
65
+ """Create tabs with compatibility for Gradio 4.x and 6.x"""
66
+ try:
67
+ # Try with selected parameter (Gradio 4.x style)
68
+ return gr.Tabs(selected=1 if self.user_profiling else 0)
69
+ except (TypeError, ValueError):
70
+ # If selected parameter not supported, create without it (Gradio 6.0+)
71
+ return gr.Tabs()
72
+
73
+ with create_tabs():
74
  # Tab 1: Setup (Cold Start/Onboarding) - only shown if user_profiling is available
75
  if self.user_profiling:
76
  with Tab("Setup"):
src/knowledge_graph.py CHANGED
@@ -321,3 +321,4 @@ class KnowledgeGraphGenerator:
321
 
322
 
323
 
 
 
321
 
322
 
323
 
324
+
src/question_generator.py CHANGED
@@ -159,3 +159,4 @@ Example JSON format:
159
 
160
 
161
 
 
 
159
 
160
 
161
 
162
+
src/rag_query.py CHANGED
@@ -116,3 +116,4 @@ class RAGQueryEngine:
116
 
117
 
118
 
 
 
116
 
117
 
118
 
119
+
src/vector_store.py CHANGED
@@ -143,3 +143,4 @@ class VectorStoreManager:
143
 
144
 
145
 
 
 
143
 
144
 
145
 
146
+