MusaR commited on
Commit
db8dc86
·
verified ·
1 Parent(s): 7c8cbbe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -2
app.py CHANGED
@@ -40,16 +40,32 @@ try:
40
  rag_pipeline = RAGPipeline()
41
  print("RAG Pipeline initialized successfully.")
42
  pipeline_status = "✅ System Ready"
 
43
  except Exception as e:
44
  print(f"FATAL: Failed to initialize RAG Pipeline: {e}")
45
  rag_pipeline = None
46
- pipeline_status = f"❌ System Error: {str(e)}"
 
47
 
48
  # --- Define the main query function ---
49
  def get_answer_from_pipeline(query, num_sources, temperature):
50
  if rag_pipeline is None:
 
51
  return (
52
- "❌ **Error**: The RAG pipeline failed to initialize on the server.",
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  "",
54
  gr.update(visible=False),
55
  0
 
40
  rag_pipeline = RAGPipeline()
41
  print("RAG Pipeline initialized successfully.")
42
  pipeline_status = "✅ System Ready"
43
+ pipeline_error = None
44
  except Exception as e:
45
  print(f"FATAL: Failed to initialize RAG Pipeline: {e}")
46
  rag_pipeline = None
47
+ pipeline_status = f"❌ System Error"
48
+ pipeline_error = str(e)
49
 
50
  # --- Define the main query function ---
51
  def get_answer_from_pipeline(query, num_sources, temperature):
52
  if rag_pipeline is None:
53
+ error_detail = pipeline_error if 'pipeline_error' in globals() else "Unknown error"
54
  return (
55
+ f"""❌ **System Initialization Error**
56
+
57
+ The RAG pipeline failed to initialize. This is usually due to one of the following:
58
+
59
+ 1. **Model Loading Error**: The LLM model failed to load. Try using a different model.
60
+ 2. **Missing Dependencies**: Ensure all required packages are installed:
61
+ ```bash
62
+ pip install ctransformers sentence-transformers faiss-cpu
63
+ ```
64
+ 3. **Insufficient Memory**: The model might be too large for your system.
65
+
66
+ **Error Details**: {error_detail}
67
+
68
+ **Suggested Fix**: Edit the pipeline.py file and switch to TinyLlama model (Option 4) for better compatibility.""",
69
  "",
70
  gr.update(visible=False),
71
  0