utkarsh134 commited on
Commit
1fe46a0
·
verified ·
1 Parent(s): a78fc53

Update services/llm_service.py

Browse files
Files changed (1) hide show
  1. services/llm_service.py +64 -66
services/llm_service.py CHANGED
@@ -1,66 +1,64 @@
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
-
9
- return ChatGoogleGenerativeAI(
10
- model=settings["llm_model"],
11
- temperature=settings["temperature"],
12
- google_api_key=settings["google_api_key"],
13
- )
14
-
15
-
16
- def get_experience_prompt():
17
- return PromptTemplate(
18
- input_variables=["resume_text", "relevant_content", "job_role"],
19
- template="""You are a professional resume analyzer with expertise in technical recruiting.
20
-
21
- Your task is to STRICTLY extract ONLY work experience from a resume that is DIRECTLY RELEVANT to the specific job role.
22
- Be extremely strict about matching - only include experience that explicitly uses the exact technologies/skills of the job role.
23
-
24
- RESUME CONTENT:
25
- {resume_text}
26
-
27
- MOST RELEVANT SECTIONS (semantically similar to job requirements):
28
- {relevant_content}
29
-
30
- TARGET JOB ROLE: {job_role}
31
-
32
- TASK INSTRUCTIONS:
33
- 1. Extract ONLY the professional work experience sections from the resume that are DIRECTLY relevant to the specified job role.
34
- 2. For each relevant position, extract specific responsibilities, projects, and achievements that directly relate to the target job role.
35
- 3. Be EXTREMELY STRICT - only include experiences that explicitly demonstrate use of the exact technologies/tools required for the job role.
36
- 4. EXCLUDE any experiences that don't directly use the core technologies of the job role.
37
- 5. EXCLUDE any projects, education, certificates, or other non-work experience sections.
38
- 6. EXCLUDE experiences that use similar but different technologies (e.g. for a Python role, exclude Ruby/PHP/JavaScript experience).
39
- 7. If NO relevant experience is found, return an empty list for relevant_experiences.
40
-
41
- For example:
42
- - For "Python Developer": ONLY include experience entries that explicitly show Python programming. Exclude experience with Java, JavaScript, PHP etc.
43
- - For "React Developer": ONLY include experience with React.js specifically. Exclude Vue.js, Angular or general JavaScript work.
44
- - For "Java Developer": ONLY include Java programming experience. Exclude Python, JavaScript or other languages.
45
-
46
- FORMAT YOUR RESPONSE AS A VALID JSON OBJECT WITH THIS EXACT STRUCTURE:
47
- {{
48
- "relevant_experiences": [
49
- {{
50
- "position": "exact job title from resume",
51
- "company": "company name",
52
- "duration": "time period(convert it into terms of year/months, i.e., 2 years, 5 months, 3 years 6 months)",
53
- "relevant_experience": "detailed description of responsibilities, projects, and achievements that specifically relate to the target job role. Focus on technical details and technologies used that match the job role requirements."
54
- }}
55
- ],
56
- "experience_summary": "comprehensive summary analyzing how ALL the candidate's relevant experiences align with the job role. Include specific examples of work done across different positions and highlight progression of skills relevant to the role. Summarize the total relevant experience and key technologies/tools used."
57
- }}
58
-
59
- IMPORTANT:
60
- - DO NOT INVENT OR ADD INFORMATION that is not in the resume
61
- - BE EXTREMELY STRICT - only include experiences that explicitly use the exact technologies of the job role
62
- - DO NOT include experiences with similar but different technologies
63
- - Make both the position-specific relevant_experience and overall experience_summary detailed and specific
64
- - Response must be a valid JSON object
65
- """,
66
- )
 
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 basic 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. If multiple educational institutions are mentioned, include the most recent one
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
+
40
+ Experience Analysis:
41
+ 1. Write a SINGLE comprehensive paragraph describing ALL relevant work experience for the target job role
42
+ 2. Focus ONLY on experiences that are DIRECTLY relevant to the specified job role
43
+ 3. Include specific responsibilities, achievements, and technologies that directly relate to the target role
44
+ 4. Be EXTREMELY STRICT - only include experiences that explicitly demonstrate relevant skills
45
+ 5. Organize the information chronologically within the single paragraph
46
+ 6. If no relevant experience is found, state this clearly
47
+
48
+ FORMAT YOUR RESPONSE AS A VALID JSON OBJECT WITH THIS EXACT STRUCTURE:
49
+ {{
50
+ "candidate_name": "full name of the candidate",
51
+ "university_name": "name of university/institute if mentioned, do not add location of institute, example : ABC College, USA, just return ABC COllege",
52
+ "location": "location of the institute if mentioned,example : ABC College, USA, just return USA",
53
+ "physical_address": "complete physical address of the candidate if mentioned",
54
+ "role": "current or most recent role/position",
55
+ "relevant_experiences": "A single comprehensive paragraph describing all relevant work experience for the target role",
56
+ "experience_summary": "brief summary analyzing how the candidate's relevant experiences align with the job role"
57
+ }}
58
+
59
+ IMPORTANT:
60
+ - DO NOT INVENT OR ADD INFORMATION that is not in the resume
61
+ - BE EXTREMELY STRICT about experience relevance
62
+ - Response must be a valid JSON object
63
+ - The relevant_experiences field must be a single text paragraph, not a list or nested object'''
64
+ )