Skip to content

Feature/recommand leetcode - #43

Merged
LiyuanLu0529 merged 2 commits into
mainfrom
feature/recommand-leetcode
Dec 1, 2025
Merged

Feature/recommand leetcode#43
LiyuanLu0529 merged 2 commits into
mainfrom
feature/recommand-leetcode

Conversation

@William-f-12

Copy link
Copy Markdown
Contributor

add a easy leetcode recommendation function in the fetching job description and analyzing module.

@LiyuanLu0529

Copy link
Copy Markdown
Contributor

all clear , good

@LiyuanLu0529
LiyuanLu0529 merged commit e0cc35e into main Dec 1, 2025
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a LeetCode problem recommendation feature to the job description analysis module. The system now uses GPT-4o-mini to recommend 3 relevant LeetCode problems based on the technical skills and requirements mentioned in a job description.

Key Changes:

  • Enhanced the analyze_jd function to include LeetCode problem recommendations in its JSON output
  • Updated the LLM prompt with rules and examples for generating appropriate problem recommendations
  • Modified the temperature parameter from 0 to 0.2 for slightly more varied outputs
  • Improved code formatting in serializers.py to follow PEP 8 style guidelines

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
backend/extraction/extractor.py Added LeetCode recommendation logic to the job description analysis prompt, including schema definition, example output, and detailed rules; updated test code to display recommendations
backend/leetcode/serializers.py Code formatting improvements (spacing, blank lines) with no functional changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -229,7 +270,7 @@ def analyze_jd(jd_text: str) -> dict:
resp = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": prompt}],

Copilot AI Dec 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The temperature change from 0 to 0.2 is undocumented. Consider adding a comment explaining why this change was made, especially since the original value of 0 was chosen for deterministic outputs.

Suggested change
messages=[{"role": "user", "content": prompt}],
messages=[{"role": "user", "content": prompt}],
# Increased temperature from 0 to 0.2 to allow slightly more flexible outputs.
# Original value (0) was chosen for deterministic results, but 0.2 yields better mappings for some job descriptions.

Copilot uses AI. Check for mistakes.
Comment on lines +212 to +223
"problem_name": "Design HashMap",
"problem_number": 706,
"difficulty": "Easy",
"reason": "Relevant for understanding data structure design in system development",
"url": "https://leetcode.com/problems/design-hashmap/"
}},
{{
"problem_name": "LRU Cache",
"problem_number": 146,
"difficulty": "Medium",
"reason": "Essential for backend caching mechanisms and performance optimization",
"url": "https://leetcode.com/problems/lru-cache/"

Copilot AI Dec 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example shows 2 Easy problems and 1 Medium problem, but the rules on line 242 suggest "1 Easy, 1 Medium, 1 Hard or 2 Medium, 1 Hard depending on seniority". The example should align with the stated rules to avoid confusing the LLM. Consider updating the example to match the difficulty distribution guidelines.

Suggested change
"problem_name": "Design HashMap",
"problem_number": 706,
"difficulty": "Easy",
"reason": "Relevant for understanding data structure design in system development",
"url": "https://leetcode.com/problems/design-hashmap/"
}},
{{
"problem_name": "LRU Cache",
"problem_number": 146,
"difficulty": "Medium",
"reason": "Essential for backend caching mechanisms and performance optimization",
"url": "https://leetcode.com/problems/lru-cache/"
"problem_name": "LRU Cache",
"problem_number": 146,
"difficulty": "Medium",
"reason": "Essential for backend caching mechanisms and performance optimization",
"url": "https://leetcode.com/problems/lru-cache/"
}},
{{
"problem_name": "Merge k Sorted Lists",
"problem_number": 23,
"difficulty": "Hard",
"reason": "Tests advanced data structures (heap/priority queue) and algorithmic thinking, relevant for backend system design",
"url": "https://leetcode.com/problems/merge-k-sorted-lists/"

Copilot uses AI. Check for mistakes.
Comment on lines +300 to +303
f"\n{i}. {problem['problem_name']} (#{problem['problem_number']}) - {problem['difficulty']}"
)
print(f" Reason: {problem['reason']}")
print(f" URL: {problem['url']}")

Copilot AI Dec 1, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential KeyError if 'problem_name', 'problem_number', 'difficulty', 'reason', or 'url' keys are missing from the LeetCode recommendation objects. Consider using .get() method with default values instead of direct dictionary access to handle cases where the LLM doesn't return the expected structure.

Suggested change
f"\n{i}. {problem['problem_name']} (#{problem['problem_number']}) - {problem['difficulty']}"
)
print(f" Reason: {problem['reason']}")
print(f" URL: {problem['url']}")
f"\n{i}. {problem.get('problem_name', 'N/A')} (#{problem.get('problem_number', 'N/A')}) - {problem.get('difficulty', 'N/A')}"
)
print(f" Reason: {problem.get('reason', 'N/A')}")
print(f" URL: {problem.get('url', 'N/A')}")

Copilot uses AI. Check for mistakes.
@William-f-12
William-f-12 deleted the feature/recommand-leetcode branch December 3, 2025 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants