Spaces:
Runtime error
Runtime error
Update services/llm_service.py
Browse files- 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.
|
| 37 |
-
6.
|
| 38 |
-
7.
|
| 39 |
-
8.
|
| 40 |
-
9.
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
"
|
| 52 |
-
"
|
| 53 |
-
"
|
| 54 |
-
"
|
| 55 |
-
"
|
| 56 |
-
"
|
| 57 |
-
"
|
| 58 |
-
"
|
| 59 |
-
"
|
| 60 |
-
"
|
| 61 |
-
"
|
| 62 |
-
"
|
| 63 |
-
"
|
| 64 |
-
"
|
| 65 |
-
"
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
-
|
| 72 |
-
-
|
| 73 |
-
-
|
| 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 |
+
)
|