Prabhas Jupalli commited on
Commit
f1e5ab9
Β·
1 Parent(s): 9bee0b4

feat: Restore full assimilation logic and UI refinements for HF push

Browse files
backend/nlp_api.py CHANGED
@@ -556,11 +556,20 @@ def create_learning_summary():
556
  if score >= hl:
557
  total_earned_base_pts += resource.get('base_points', 50)
558
 
 
 
 
 
 
 
559
  high_line_sum = max(0.1, high_line_sum)
560
- xp_earned = int(total_earned_base_pts * (current_polyline_sum / high_line_sum))
 
 
 
561
 
562
- # Update session with new XP
563
- session['totalReward'] = session.get('totalReward', 0) + xp_earned
564
  session = sync_agent_progression(session)
565
  update_session(session_id, session)
566
 
@@ -631,10 +640,13 @@ def create_learning_summary():
631
  'name': 'Current Average Knowledge',
632
  'module_scores': avg_scores,
633
  'isActive': True,
634
- 'color': 'rgba(59, 130, 246, 0.8)'
 
635
  },
636
  'next_recommendation': new_polyline['next_recommendation'],
637
- 'keywords_found': keywords_found
 
 
638
  })
639
 
640
 
@@ -642,7 +654,6 @@ def create_learning_summary():
642
  # POLYLINE ENDPOINTS
643
  # =============================================
644
 
645
- @app.route('/api/polylines', methods=['GET'])
646
  @app.route('/api/polylines', methods=['GET'])
647
  def get_polylines_route():
648
  """Get all polylines including dynamically generated High Line and Current Average polylines"""
 
556
  if score >= hl:
557
  total_earned_base_pts += resource.get('base_points', 50)
558
 
559
+ # ──── XP SYNC & REWARD CALCULATION ──────────────────────────
560
+ # Ensure backend Reward stays synced with frontend.
561
+ current_reward = session.get('totalReward', 0)
562
+ base_visited_reward = sum(r.get('reward', 50) for r in visited_resources)
563
+
564
+ # Calculate summary quality bonus
565
  high_line_sum = max(0.1, high_line_sum)
566
+ summary_bonus = int(total_earned_base_pts * (current_polyline_sum / high_line_sum))
567
+
568
+ # Final XP Earned (ensure participation reward)
569
+ xp_earned = max(25, summary_bonus)
570
 
571
+ # Update session (ensuring no point loss)
572
+ session['totalReward'] = max(current_reward, base_visited_reward) + xp_earned
573
  session = sync_agent_progression(session)
574
  update_session(session_id, session)
575
 
 
640
  'name': 'Current Average Knowledge',
641
  'module_scores': avg_scores,
642
  'isActive': True,
643
+ 'color': 'rgba(59, 130, 246, 0.8)',
644
+ 'assimilation_position': radial_mapper.polyline_to_grid(avg_scores, num_topics=len(ordered_modules))
645
  },
646
  'next_recommendation': new_polyline['next_recommendation'],
647
+ 'keywords_found': keywords_found,
648
+ 'totalReward': session['totalReward'],
649
+ 'xp_earned': xp_earned
650
  })
651
 
652
 
 
654
  # POLYLINE ENDPOINTS
655
  # =============================================
656
 
 
657
  @app.route('/api/polylines', methods=['GET'])
658
  def get_polylines_route():
659
  """Get all polylines including dynamically generated High Line and Current Average polylines"""
src/components/GridVisualization.tsx CHANGED
@@ -507,7 +507,7 @@ export const GridVisualization: React.FC<GridVisualizationProps> = ({
507
  <div className={`
508
  relative flex items-center justify-center
509
  w-10 h-10 transform transition-all duration-300
510
- ${selectedResource?.id === resource.id ? 'scale-110' : 'hover:scale-110 hover:-translate-y-1'}
511
  `}>
512
  {/* Outer Glow */}
513
  <div className={`absolute inset-0 rounded-full blur-[8px] opacity-25 ${
@@ -528,6 +528,11 @@ export const GridVisualization: React.FC<GridVisualizationProps> = ({
528
  `}>
529
  <ResourceIcon type={resource.type} />
530
  </div>
 
 
 
 
 
531
 
532
  {/* Current Resource Highlight - pulsing golden ring */}
533
  {currentResource?.id === resource.id && (
@@ -851,16 +856,29 @@ export const GridVisualization: React.FC<GridVisualizationProps> = ({
851
  }}
852
  transition={{ duration: 2.5, repeat: Infinity, ease: 'easeInOut' }}
853
  />
854
- {/* Diamond marker */}
855
- <div
856
- className="relative w-5 h-5 flex items-center justify-center"
857
- style={{ transform: 'rotate(45deg)' }}
858
- >
 
 
 
 
 
 
 
 
859
  <div
860
- className="w-4 h-4 rounded-sm shadow-lg border-2 border-white"
861
- style={{ backgroundColor: point.color }}
862
- />
863
- </div>
 
 
 
 
 
864
  {/* Label tooltip below */}
865
  <div
866
  className="absolute top-[calc(100%+2px)] left-1/2 -translate-x-1/2 whitespace-nowrap"
 
507
  <div className={`
508
  relative flex items-center justify-center
509
  w-10 h-10 transform transition-all duration-300
510
+ ${currentResource?.id === resource.id ? 'scale-150 z-50 animate-pulse' : (selectedResource?.id === resource.id ? 'scale-110' : 'hover:scale-110 hover:-translate-y-1')}
511
  `}>
512
  {/* Outer Glow */}
513
  <div className={`absolute inset-0 rounded-full blur-[8px] opacity-25 ${
 
528
  `}>
529
  <ResourceIcon type={resource.type} />
530
  </div>
531
+
532
+ {/* Current Resource "Pop-out" Highlight */}
533
+ {currentResource?.id === resource.id && (
534
+ <div className="absolute inset-[-12px] rounded-full bg-blue-400/20 blur-xl animate-pulse pointer-events-none" />
535
+ )}
536
 
537
  {/* Current Resource Highlight - pulsing golden ring */}
538
  {currentResource?.id === resource.id && (
 
856
  }}
857
  transition={{ duration: 2.5, repeat: Infinity, ease: 'easeInOut' }}
858
  />
859
+ {/* Icon/Marker Rendering */}
860
+ {point.id === 'current_average' ? (
861
+ /* Avatar Icon for Average Knowledge */
862
+ <div className="relative w-10 h-10 rounded-full border-2 border-white shadow-xl overflow-hidden bg-white p-0.5 animate-in zoom-in-50 duration-500">
863
+ <img
864
+ src={avatar}
865
+ alt="Current Average"
866
+ className="w-full h-full rounded-full object-cover"
867
+ />
868
+ <div className="absolute bottom-0 right-0 w-2.5 h-2.5 bg-blue-500 border border-white rounded-full shadow-sm" />
869
+ </div>
870
+ ) : (
871
+ /* Standard Diamond for Peak Potential */
872
  <div
873
+ className="relative w-5 h-5 flex items-center justify-center"
874
+ style={{ transform: 'rotate(45deg)' }}
875
+ >
876
+ <div
877
+ className="w-4 h-4 rounded-sm shadow-lg border-2 border-white"
878
+ style={{ backgroundColor: point.color }}
879
+ />
880
+ </div>
881
+ )}
882
  {/* Label tooltip below */}
883
  <div
884
  className="absolute top-[calc(100%+2px)] left-1/2 -translate-x-1/2 whitespace-nowrap"