Spaces:
Runtime error
Runtime error
Update services/llm_service.py
Browse files- 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 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 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 |
-
)
|
|
|
|
| 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 |
+
)
|
|
|
|
|
|