Skip to content

Commit ee15d1c

Browse files
committed
Add Prompt To AI For Resume Scoring
Signed-off-by: Tal Jacob <taljacob2@gmail.com>
1 parent df6d457 commit ee15d1c

File tree

5 files changed

+69
-18
lines changed

5 files changed

+69
-18
lines changed

nextstep-backend/src/controllers/resources_controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import multer from 'multer';
77
import {CustomRequest} from "types/customRequest";
88
import {updateUserById} from "../services/users_service";
99
import {handleError} from "../utils/handle_error";
10-
import { scoreResume } from '../services/resume_service';
1110

1211
const createUserImageResource = async (req: CustomRequest, res: Response) => {
1312
try {

nextstep-backend/src/controllers/resume_controller.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ const getResumeScore = async (req: Request, res: Response) => {
1717
return res.status(404).send('Resume not found');
1818
}
1919

20-
const score = await scoreResume(resumePath, jobDescription);
21-
return res.status(200).json({ score });
20+
const scoreAndFeedback = await scoreResume(resumePath, jobDescription);
21+
return res.status(200).send(scoreAndFeedback);
2222
} catch (error) {
2323
handleError(error, res);
2424
}
2525
};
2626

2727

28-
2928
export default {
3029
getResumeScore,
3130
};

nextstep-backend/src/services/chat_api_service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ const cleanResponse = (response: string): string => {
77

88

99

10-
export const chatWithAI = async (inputUserMessage: string)=> {
10+
export const chatWithAI = async (userMessageContent: string, systemMessageContent: string)=> {
1111
try {
1212
const API_URL = config.chatAi.api_url();
1313
const API_KEY = config.chatAi.api_key();
1414
const MODEL_NAME = config.chatAi.model_name();
1515

1616
const systemMessage = {
1717
role: 'system',
18-
content: 'You are an AI assistant tasked with providing the first comment on forum posts. Your responses should be relevant, engaging, and encourage further discussion, also must be short, and you must answer if you know the answer. Ensure your comments are appropriate for the content and tone of the post. Also must answer in the language of the user post. answer short answers. dont ask questions to follow up'
18+
content: systemMessageContent
1919
};
2020

2121
const userMessage = {
2222
role: 'user',
23-
content: inputUserMessage
23+
content: userMessageContent
2424
};
2525

2626

nextstep-backend/src/services/posts_service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const addMisterAIComment = async (postId: string, postContent: string) => {
3232
misterAI = await usersService.addUser('misterai', 'securepassword', 'misterai@example.com', 'local');
3333
}
3434

35-
const comment = await chatService.chatWithAI(postContent);
35+
const comment = await chatService.chatWithAI(postContent, 'You are an AI assistant tasked with providing the first comment on forum posts. Your responses should be relevant, engaging, and encourage further discussion, also must be short, and you must answer if you know the answer. Ensure your comments are appropriate for the content and tone of the post. Also must answer in the language of the user post. answer short answers. dont ask questions to follow up');
3636
const commentData: CommentData = { postId, owner: misterAI.id, content: comment };
3737
const savedComment = await commentsService.addComment(commentData);
3838
return savedComment;

nextstep-backend/src/services/resume_service.ts

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,73 @@ import { config } from '../config/config';
22
import path from 'path';
33
import fs from 'fs';
44
import axios from 'axios';
5+
import { chatWithAI } from './chat_api_service';
56

6-
const scoreResume = async (resumePath: string, jobDescription?: string): Promise<number> => {
7+
const systemTemplate = `You are a very experienced ATS (Application Tracking System) bot with a deep understanding named Bob the Resume builder.
8+
You will review resumes with or without job descriptions.
9+
You are an expert in resume evaluation and provide constructive feedback with dynamic evaluation.
10+
You should also provide an improvement table, taking into account:
11+
- Content (Medium priority)
12+
- Keyword matching (High priority)
13+
- Hard skills (High priority)
14+
- Soft skills (High priority)
15+
- Overall presentation (Low priority)`;
16+
17+
const feedbackTemplate = (resumeText: string, jdText: string) => `
18+
Resume Feedback Report
19+
Here is the resume you provided:
20+
${resumeText}
21+
And the job description:
22+
${jdText}
23+
24+
Create the Improvement Table in relevance to the resume and give the consideration and suggestion for each section strictly following
25+
the pattern as below and don't just out this guided pattern :
26+
| Area | Consideration | Status | Suggestions |
27+
| ------------- | --------------------------------------------------------------- | ------ | ----------- |
28+
| Content | Measurable Results: At least 5 specific achievements or impact. | Low | |
29+
| | Words to avoid: Negative phrases or clichés. | | |
30+
| Keywords | Hard Skills: Presence and frequency of hard skills. | High | |
31+
| | Soft Skills: Presence and frequency of soft skills. | | |
32+
| Presentation | Education Match: Does the resume list a degree that matches the job requirements? | High | |
33+
34+
Strengths:
35+
List the strengths of the resume here.
36+
37+
Detailed Feedback:
38+
Provide detailed feedback on the resume's content, structure, grammar, and relevance to the job description.
39+
40+
Suggestions:
41+
Provide actionable suggestions for improvement, including specific keywords to include and skills to highlight.
42+
43+
Based on your analysis, provide a numerical score between 0-100 that represents the overall quality and match of the resume.
44+
The score should be provided at the end of your response in the format: "SCORE: X" where X is the numerical score.
45+
`;
46+
47+
const scoreResume = async (resumePath: string, jobDescription?: string): Promise<{ score: number; feedback: string }> => {
748
try {
8-
// Here you would integrate with an actual ATS system
9-
// For now, we'll return a mock score
10-
// In a real implementation, you would:
11-
// 1. Parse the resume text
12-
// 2. Compare it with the job description
13-
// 3. Calculate a score based on keywords, skills, experience, etc.
49+
// Read the resume file
50+
const resumeText = fs.readFileSync(resumePath, 'utf-8');
51+
52+
// Prepare the prompt for the AI
53+
const prompt = feedbackTemplate(resumeText, jobDescription || 'No job description provided.');
54+
55+
let feedback = 'This Chat AI feature is turned off. Could not score your resume.';
56+
57+
if (config.chatAi.turned_on()) {
58+
// Get feedback from the AI
59+
feedback = await chatWithAI(prompt, systemTemplate);
60+
}
61+
62+
// Extract the score from the feedback
63+
const scoreMatch = feedback.match(/SCORE: (\d+)/);
64+
const score = scoreMatch ? parseInt(scoreMatch[1]) : 0;
1465

15-
// Mock implementation
16-
const score = Math.floor(Math.random() * 100);
17-
return score;
66+
return {
67+
score,
68+
feedback
69+
};
1870
} catch (error) {
71+
console.error('Error scoring resume:', error);
1972
throw new Error('Failed to score resume');
2073
}
2174
};

0 commit comments

Comments
 (0)