Bryceeee commited on
Commit
28c5e04
Β·
verified Β·
1 Parent(s): 3f7a0f7

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -25
app.py CHANGED
@@ -252,29 +252,22 @@ def create_app():
252
 
253
  # Create the app for Hugging Face Spaces
254
  # Spaces will automatically detect Gradio and run this
255
- # Use a guard to prevent multiple initializations (Spaces may import the module multiple times)
256
- _demo_initialized = False
257
-
258
- if not _demo_initialized:
259
- try:
260
- print("πŸ”„ Initializing app...")
261
- demo = create_app()
262
- _demo_initialized = True
263
- print("βœ… App initialized successfully!")
264
- except Exception as e:
265
- print(f"❌ Error creating app: {e}")
266
- import traceback
267
- traceback.print_exc()
268
- # Create a minimal error interface
269
- import gradio as gr
270
- demo = gr.Interface(
271
- fn=lambda: f"Error: {str(e)}\n\nPlease check the logs for details.",
272
- inputs=None,
273
- outputs=gr.Textbox(),
274
- title="CSRC Car Manual RAG System - Error",
275
- description="An error occurred during initialization. Please check the logs."
276
- )
277
- _demo_initialized = True
278
- else:
279
- print("ℹ️ App already initialized, reusing existing instance")
280
 
 
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