Upload app.py
Browse files
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"π―
|
| 583 |
-
|
| 584 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 599 |
challenges = real_challenges
|
| 600 |
-
data_source = "π₯ REAL Topcoder MCP Server (
|
| 601 |
-
print(f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
else:
|
| 603 |
challenges = self.mock_challenges
|
| 604 |
-
data_source = "
|
| 605 |
-
print(f"
|
|
|
|
| 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 |
-
|
| 619 |
-
|
| 620 |
-
|
|
|
|
|
|
|
|
|
|
| 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": "
|
| 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 |
|