Prabhas Jupalli commited on
Commit
a458ae1
·
1 Parent(s): f1e5ab9

opt: Restore startup loading and remove redundant player icon

Browse files
backend/nlp_api.py CHANGED
@@ -51,19 +51,16 @@ def log_polyline_step(step, details):
51
  with open(POLYLINE_LOG_FILE, 'a', encoding='utf-8') as f:
52
  f.write(f"[{timestamp}] [{step}]\n{details}\n{'-'*50}\n")
53
 
54
- _bert_model = None
 
 
 
 
 
 
 
55
 
56
  def get_bert_model():
57
- global _bert_model
58
- if _bert_model is None:
59
- try:
60
- from sentence_transformers import SentenceTransformer
61
- print("Loading BERT model (lazy)...")
62
- _bert_model = SentenceTransformer('all-MiniLM-L6-v2')
63
- print("BERT model loaded successfully")
64
- except Exception as e:
65
- print(f"Error loading BERT model: {e}")
66
- _bert_model = None
67
  return _bert_model
68
 
69
  # Load NLP data from JSON (Excel was rejected by HF)
@@ -234,8 +231,8 @@ def compute_module_embeddings():
234
  module_embeddings[m] = bert_model.encode(clean_doc)
235
  print(f"Computed embeddings for {len(module_embeddings)} modules")
236
 
237
- # Compute embeddings on startup (REMOVED: Too slow on startup, will compute lazily or skip if needed)
238
- # compute_module_embeddings()
239
 
240
  # =============================================
241
  # RESOURCES ENDPOINTS
 
51
  with open(POLYLINE_LOG_FILE, 'a', encoding='utf-8') as f:
52
  f.write(f"[{timestamp}] [{step}]\n{details}\n{'-'*50}\n")
53
 
54
+ try:
55
+ from sentence_transformers import SentenceTransformer
56
+ print("Loading BERT model (on startup)...")
57
+ _bert_model = SentenceTransformer('all-MiniLM-L6-v2')
58
+ print("BERT model loaded successfully")
59
+ except Exception as e:
60
+ print(f"Error loading BERT model: {e}")
61
+ _bert_model = None
62
 
63
  def get_bert_model():
 
 
 
 
 
 
 
 
 
 
64
  return _bert_model
65
 
66
  # Load NLP data from JSON (Excel was rejected by HF)
 
231
  module_embeddings[m] = bert_model.encode(clean_doc)
232
  print(f"Computed embeddings for {len(module_embeddings)} modules")
233
 
234
+ # Compute embeddings on startup for immediate availability
235
+ compute_module_embeddings()
236
 
237
  # =============================================
238
  # RESOURCES ENDPOINTS
src/components/GridVisualization.tsx CHANGED
@@ -897,7 +897,8 @@ export const GridVisualization: React.FC<GridVisualizationProps> = ({
897
  </motion.div>
898
  ))}
899
 
900
- {/* Animated Student Agent Marker */}
 
901
  <motion.div
902
  key={`agent-at-${agent.position.x}-${agent.position.y}`}
903
  className="absolute pointer-events-none z-40 flex items-center justify-center"
@@ -923,6 +924,7 @@ export const GridVisualization: React.FC<GridVisualizationProps> = ({
923
  >
924
  <SocialAgent isMoving={isPlaying} />
925
  </motion.div>
 
926
 
927
  {showTravelArrow && (
928
  <svg className="absolute inset-0 w-full h-full pointer-events-none z-30">
 
897
  </motion.div>
898
  ))}
899
 
900
+ {/* Animated Student Agent Marker - Removed per user request */}
901
+ {/*
902
  <motion.div
903
  key={`agent-at-${agent.position.x}-${agent.position.y}`}
904
  className="absolute pointer-events-none z-40 flex items-center justify-center"
 
924
  >
925
  <SocialAgent isMoving={isPlaying} />
926
  </motion.div>
927
+ */}
928
 
929
  {showTravelArrow && (
930
  <svg className="absolute inset-0 w-full h-full pointer-events-none z-30">