utkarsh134 commited on
Commit
bfdd2c7
·
verified ·
1 Parent(s): f7b24b5

Update services/llm_service.py

Browse files
Files changed (1) hide show
  1. services/llm_service.py +76 -74
services/llm_service.py CHANGED
@@ -1,74 +1,76 @@
1
- from langchain_google_genai import ChatGoogleGenerativeAI
2
- from langchain.prompts import PromptTemplate
3
- from config.settings import get_settings
4
-
5
-
6
- def get_llm():
7
- settings = get_settings()
8
- return ChatGoogleGenerativeAI(
9
- model=settings["llm_model"],
10
- temperature=settings["temperature"],
11
- google_api_key=settings["google_api_key"],
12
- )
13
-
14
-
15
- def get_unified_resume_prompt():
16
- return PromptTemplate(
17
- input_variables=["resume_text", "relevant_content", "job_role"],
18
- template='''You are a professional resume analyzer with expertise in technical recruiting.
19
-
20
- Your task is to extract both basic information and relevant work experience from the resume.
21
-
22
- RESUME CONTENT:
23
- {resume_text}
24
-
25
- MOST RELEVANT SECTIONS (semantically similar to job requirements):
26
- {relevant_content}
27
-
28
- TARGET JOB ROLE: {job_role}
29
-
30
- TASK INSTRUCTIONS:
31
- Basic Information:
32
- 1. Extract all personally identifiable information that is explicitly stated in the text
33
- 2. For fields where information is not found, use null
34
- 3. Do not invent or infer information not present in the text
35
- 4. For education, only return the highest level completed (postgraduate > undergraduate > 12th > 10th)
36
- 5. For role, use the most recent/current position mentioned
37
- 6. Return complete values - do not truncate or summarize unnecessarily
38
- 7. Maintain exact formatting/capitalization as shown in the resume
39
- 8. Extract all contact information including email and phone number (just the primary number)
40
- 9. Look for any government ID numbers (PAN, Aadhar, Passport) that might be present
41
-
42
- Experience Analysis:
43
- 1. Create a single concise paragraph summarizing ALL relevant professional experience that directly relates to the job role
44
- 2. Focus only on experiences that explicitly demonstrate use of the exact technologies/tools required
45
- 3. If NO relevant experience is found, return null for relevant_experience
46
- 4. Provide a brief summary analyzing how well the candidate's experience matches the job role
47
-
48
- FORMAT YOUR RESPONSE AS A VALID JSON OBJECT WITH THIS EXACT STRUCTURE:
49
- {{
50
- "candidate_name": "full name of the candidate",
51
- "gender": "gender if mentioned",
52
- "date_of_birth": "DOB in YYYY/MM/DD format if mentioned",
53
- "email": "email address if mentioned",
54
- "mobile_number": "primary phone number if mentioned",
55
- "address": "complete physical address if mentioned",
56
- "pan_number": "PAN number if mentioned",
57
- "aadhar_number": "Aadhar number if mentioned",
58
- "passport_number": "Passport number if mentioned",
59
- "highest_education": "most advanced completed education level, interpret from the data and return only 4 of these options : 10th, 12th, UG, PG",
60
- "designation": "current or most recent role/position",
61
- "skills": "comma-separated list of technical and professional skills",
62
- "total_experience": "total work experience in terms of years i.e., if experience is 6 months return "0.5", divide the number of months found by 12 and return the number as a string",
63
- "region": "geographical region/city of work",
64
- "relevant_experience": "single paragraph summarizing all experience relevant to the job role",
65
- "experience_summary": "brief analysis of how well the experience matches the job role"
66
- }}
67
-
68
- IMPORTANT:
69
- - DO NOT INVENT OR ADD INFORMATION that is not in the resume
70
- - BE EXTREMELY STRICT about experience relevance
71
- - Response must be a valid JSON object
72
- - For sensitive information like Aadhar/PAN, return only if explicitly mentioned in resume
73
- - Skills should be returned as a comma-separated string (e.g. "Java, Spring Boot, Docker, AWS, PostgreSQL")'''
74
- )
 
 
 
1
+ from langchain_google_genai import ChatGoogleGenerativeAI
2
+ from langchain.prompts import PromptTemplate
3
+ from config.settings import get_settings
4
+
5
+
6
+ def get_llm():
7
+ settings = get_settings()
8
+ return ChatGoogleGenerativeAI(
9
+ model=settings["llm_model"],
10
+ temperature=settings["temperature"],
11
+ google_api_key=settings["google_api_key"],
12
+ )
13
+
14
+
15
+ def get_unified_resume_prompt():
16
+ return PromptTemplate(
17
+ input_variables=["resume_text", "relevant_content", "job_role"],
18
+ template='''You are a professional resume analyzer with expertise in technical recruiting.
19
+
20
+ Your task is to extract both basic information and relevant work experience from the resume.
21
+
22
+ RESUME CONTENT:
23
+ {resume_text}
24
+
25
+ MOST RELEVANT SECTIONS (semantically similar to job requirements):
26
+ {relevant_content}
27
+
28
+ TARGET JOB ROLE: {job_role}
29
+
30
+ TASK INSTRUCTIONS:
31
+ Basic Information:
32
+ 1. Extract all personally identifiable information that is explicitly stated in the text
33
+ 2. For fields where information is not found, use null
34
+ 3. Do not invent or infer information not present in the text
35
+ 4. For education, only return the highest level completed (postgraduate > undergraduate > 12th > 10th)
36
+ 5. Extract the university/institution name for the highest education qualification
37
+ 6. For role, use the most recent/current position mentioned
38
+ 7. Return complete values - do not truncate or summarize unnecessarily
39
+ 8. Maintain exact formatting/capitalization as shown in the resume
40
+ 9. Extract all contact information including email and phone number (just the primary number)
41
+ 10. Look for any government ID numbers (PAN, Aadhar, Passport) that might be present
42
+
43
+ Experience Analysis:
44
+ 1. Create a single concise paragraph summarizing ALL relevant professional experience that directly relates to the job role
45
+ 2. Focus only on experiences that explicitly demonstrate use of the exact technologies/tools required
46
+ 3. If NO relevant experience is found, return null for relevant_experience
47
+ 4. Provide a brief summary analyzing how well the candidate's experience matches the job role
48
+
49
+ FORMAT YOUR RESPONSE AS A VALID JSON OBJECT WITH THIS EXACT STRUCTURE:
50
+ {{
51
+ "candidate_name": "full name of the candidate",
52
+ "gender": "gender if mentioned",
53
+ "date_of_birth": "DOB in YYYY/MM/DD format if mentioned",
54
+ "email": "email address if mentioned",
55
+ "mobile_number": "primary phone number if mentioned",
56
+ "address": "complete physical address if mentioned",
57
+ "pan_number": "PAN number if mentioned",
58
+ "aadhar_number": "Aadhar number if mentioned",
59
+ "passport_number": "Passport number if mentioned",
60
+ "highest_education": "most advanced completed education level, interpret from the data and return only 4 of these options : 10th, 12th, Undergraduate, PostGraduate,
61
+ "university_name": "name of the university/institution where highest education was completed",
62
+ "designation": "current or most recent role/position",
63
+ "skills": "comma-separated list of technical and professional skills",
64
+ "total_experience": "total work experience in terms of years i.e., if experience is 6 months return "0.5", divide the number of months found by 12 and return the number as a string",
65
+ "region": "geographical region/city of work",
66
+ "relevant_experience": "single paragraph summarizing all experience relevant to the job role. If no relevant experience found,reply with a message regarding the same",
67
+ "experience_summary": "brief analysis of how well the experience matches the job role"
68
+ }}
69
+
70
+ IMPORTANT:
71
+ - DO NOT INVENT OR ADD INFORMATION that is not in the resume
72
+ - BE EXTREMELY STRICT about experience relevance
73
+ - Response must be a valid JSON object
74
+ - For sensitive information like Aadhar/PAN, return only if explicitly mentioned in resume
75
+ - Skills should be returned as a comma-separated string (e.g. "Java, Spring Boot, Docker, AWS, PostgreSQL")'''
76
+ )