Feature/recommand leetcode - #43
Conversation
|
all clear , good |
There was a problem hiding this comment.
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_jdfunction 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.pyto 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}], | |||
There was a problem hiding this comment.
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.
| 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. |
| "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/" |
There was a problem hiding this comment.
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.
| "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/" |
| f"\n{i}. {problem['problem_name']} (#{problem['problem_number']}) - {problem['difficulty']}" | ||
| ) | ||
| print(f" Reason: {problem['reason']}") | ||
| print(f" URL: {problem['url']}") |
There was a problem hiding this comment.
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.
| 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')}") |
add a easy leetcode recommendation function in the fetching job description and analyzing module.