pranavkv commited on
Commit
4763db2
Β·
verified Β·
1 Parent(s): a7b642e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -12
app.py CHANGED
@@ -578,10 +578,16 @@ class UltimateTopcoderMCPEngine:
578
  sort_by: str = None, sort_order: str = None,
579
  limit: int = 50
580
  ) -> Dict[str, Any]:
 
581
  start_time = datetime.now()
582
- print(f"🎯 Analyzing profile: {user_profile.skills} | Level: {user_profile.experience_level}")
583
-
584
- # FIXED: More aggressive real data fetching
 
 
 
 
 
585
  real_challenges = await self.fetch_real_challenges(
586
  user_profile=user_profile,
587
  query=query,
@@ -595,29 +601,45 @@ class UltimateTopcoderMCPEngine:
595
  sort_order=sort_order,
596
  )
597
 
598
- if real_challenges:
 
 
 
599
  challenges = real_challenges
600
- data_source = "πŸ”₯ REAL Topcoder MCP Server (4,596+ challenges)"
601
- print(f"πŸŽ‰ Using {len(challenges)} REAL Topcoder challenges!")
 
 
 
 
 
602
  else:
603
  challenges = self.mock_challenges
604
- data_source = "✨ Enhanced Intelligence Engine (Premium Dataset)"
605
- print(f"⚑ Using {len(challenges)} premium challenges with advanced algorithms")
 
606
 
 
 
607
  scored_challenges = []
608
  for challenge in challenges:
609
  score, factors = self.calculate_advanced_compatibility_score(challenge, user_profile, query)
610
  challenge.compatibility_score = score
611
  challenge.rationale = f"Match: {score:.0f}%. " + ". ".join(factors[:2]) + "."
612
  scored_challenges.append(challenge)
 
613
  scored_challenges.sort(key=lambda x: x.compatibility_score, reverse=True)
614
  recommendations = scored_challenges[:5]
 
615
  processing_time = (datetime.now() - start_time).total_seconds()
616
  query_techs = self.extract_technologies_from_query(query)
617
  avg_score = sum(c.compatibility_score for c in challenges) / len(challenges) if challenges else 0
618
- print(f"βœ… Generated {len(recommendations)} recommendations in {processing_time:.3f}s:")
619
- for i, rec in enumerate(recommendations, 1):
620
- print(f" {i}. {rec.title} - {rec.compatibility_score:.0f}% compatibility")
 
 
 
621
  return {
622
  "recommendations": [asdict(rec) for rec in recommendations],
623
  "insights": {
@@ -630,7 +652,7 @@ class UltimateTopcoderMCPEngine:
630
  "session_active": bool(self.session_id),
631
  "mcp_connected": self.is_connected,
632
  "algorithm_version": "Advanced Multi-Factor v2.0",
633
- "topcoder_total": "4,596+ live challenges" if real_challenges else "Premium dataset"
634
  }
635
  }
636
 
 
578
  sort_by: str = None, sort_order: str = None,
579
  limit: int = 50
580
  ) -> Dict[str, Any]:
581
+ """FIXED: Debug the actual recommendation flow"""
582
  start_time = datetime.now()
583
+ print(f"\n🎯 === STARTING RECOMMENDATION REQUEST ===")
584
+ print(f"🎯 User skills: {user_profile.skills}")
585
+ print(f"🎯 Query: '{query}'")
586
+ print(f"🎯 Status filter: {status}")
587
+ print(f"🎯 Limit: {limit}")
588
+
589
+ # FIXED: Try to get real challenges with detailed debugging
590
+ print(f"\nπŸ”„ Step 1: Attempting to fetch REAL challenges...")
591
  real_challenges = await self.fetch_real_challenges(
592
  user_profile=user_profile,
593
  query=query,
 
601
  sort_order=sort_order,
602
  )
603
 
604
+ print(f"πŸ“Š Step 2: fetch_real_challenges returned {len(real_challenges)} challenges")
605
+
606
+ # Determine data source and challenges to use
607
+ if real_challenges and len(real_challenges) > 0:
608
  challenges = real_challenges
609
+ data_source = f"πŸ”₯ REAL Topcoder MCP Server ({len(challenges)} live challenges)"
610
+ print(f"βœ… Step 3: Using {len(challenges)} REAL MCP challenges!")
611
+
612
+ # Show sample challenge details
613
+ if challenges:
614
+ sample = challenges[0]
615
+ print(f"πŸ“‹ Sample real challenge: {sample.title} | {sample.prize} | {sample.technologies}")
616
  else:
617
  challenges = self.mock_challenges
618
+ data_source = "⚑ Enhanced Intelligence Engine (Premium Dataset)"
619
+ print(f"⚠️ Step 3: No real challenges returned, using {len(challenges)} fallback challenges")
620
+ print(f"πŸ” Debug: Why no real challenges? Check fetch_real_challenges output above")
621
 
622
+ # Score and rank challenges
623
+ print(f"\n🧠 Step 4: Scoring {len(challenges)} challenges...")
624
  scored_challenges = []
625
  for challenge in challenges:
626
  score, factors = self.calculate_advanced_compatibility_score(challenge, user_profile, query)
627
  challenge.compatibility_score = score
628
  challenge.rationale = f"Match: {score:.0f}%. " + ". ".join(factors[:2]) + "."
629
  scored_challenges.append(challenge)
630
+
631
  scored_challenges.sort(key=lambda x: x.compatibility_score, reverse=True)
632
  recommendations = scored_challenges[:5]
633
+
634
  processing_time = (datetime.now() - start_time).total_seconds()
635
  query_techs = self.extract_technologies_from_query(query)
636
  avg_score = sum(c.compatibility_score for c in challenges) / len(challenges) if challenges else 0
637
+
638
+ print(f"βœ… Step 5: Generated {len(recommendations)} recommendations in {processing_time:.3f}s")
639
+ print(f"πŸ† Top recommendation: {recommendations[0].title} ({recommendations[0].compatibility_score:.0f}%)")
640
+ print(f"πŸ“Š Data source being reported: {data_source}")
641
+ print(f"🎯 === RECOMMENDATION REQUEST COMPLETE ===\n")
642
+
643
  return {
644
  "recommendations": [asdict(rec) for rec in recommendations],
645
  "insights": {
 
652
  "session_active": bool(self.session_id),
653
  "mcp_connected": self.is_connected,
654
  "algorithm_version": "Advanced Multi-Factor v2.0",
655
+ "topcoder_total": f"{len(challenges)} challenges analyzed"
656
  }
657
  }
658