paulhemb commited on
Commit
1fb4f83
·
verified ·
1 Parent(s): e8251f8

Update chat/rag_engine.py

Browse files
Files changed (1) hide show
  1. chat/rag_engine.py +29 -3
chat/rag_engine.py CHANGED
@@ -342,10 +342,11 @@ import os
342
 
343
  # Add the project root to Python path
344
  current_dir = os.path.dirname(os.path.abspath(__file__))
345
- parent_dir = os.path.dirname(current_dir) # This goes from chat/ to MedSearchPro/
346
 
347
- if parent_dir not in sys.path:
348
- sys.path.insert(0, parent_dir)
 
349
 
350
 
351
  # Import existing modules
@@ -360,6 +361,15 @@ try:
360
  except ImportError as e:
361
  print(f"⚠️ Some dependencies not found - using simplified mode: {e}")
362
 
 
 
 
 
 
 
 
 
 
363
  # Import config for domain mapping
364
  try:
365
  from config.domains import (
@@ -1140,6 +1150,22 @@ class EnhancedRAGEngine:
1140
  print("⚠️ Using fallback mode - will generate demo papers")
1141
  self.RESEARCH_ENGINE_AVAILABLE = False
1142
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1143
  # Initialize components
1144
  try:
1145
  self.llm = GrokLLM(model=self.model)
 
342
 
343
  # Add the project root to Python path
344
  current_dir = os.path.dirname(os.path.abspath(__file__))
345
+ project_root = os.path.dirname(current_dir) # This goes from chat/ to MedSearchPro/
346
 
347
+ if project_root not in sys.path:
348
+ sys.path.insert(0, project_root)
349
+ print(f"✅ Added project root to sys.path: {project_root}")
350
 
351
 
352
  # Import existing modules
 
361
  except ImportError as e:
362
  print(f"⚠️ Some dependencies not found - using simplified mode: {e}")
363
 
364
+ # Set fallback values for all imported modules
365
+ VectorStore = None
366
+ MultiDocumentSummarizer = None
367
+ SinglePaperSummarizer = None
368
+ CrossPaperComparator = None
369
+ ResearchGapAnalyzer = None
370
+ ConversationMemory = None
371
+ GrokLLM = None
372
+
373
  # Import config for domain mapping
374
  try:
375
  from config.domains import (
 
1150
  print("⚠️ Using fallback mode - will generate demo papers")
1151
  self.RESEARCH_ENGINE_AVAILABLE = False
1152
 
1153
+ # Initialize LLM - FIXED IMPORT
1154
+ try:
1155
+ # Ensure we can import from llm directory
1156
+ import sys
1157
+ import os
1158
+
1159
+ # Get the project root (MedSearchPro/
1160
+ current_dir = os.path.dirname(os.path.abspath(__file__)) # /MedSearchPro/chat/
1161
+ project_root = os.path.dirname(current_dir)
1162
+
1163
+ if project_root not in sys.path:
1164
+ sys.path.insert(0, project_root)
1165
+
1166
+ # Now importing GrokLLM
1167
+ from llm.llm_provider import GrokLLM
1168
+
1169
  # Initialize components
1170
  try:
1171
  self.llm = GrokLLM(model=self.model)