Spaces:
Runtime error
Runtime error
Download services/llm_service.py from utkarsh134/FastAPIExperience2: direct link, hf CLI and curl.
- Browser
- Download file 6.23 kB
-
https://huggingface.co/spaces/utkarsh134/FastAPIExperience2/resolve/main/services/llm_service.py
- Command line
-
hf download hf://spaces/utkarsh134/FastAPIExperience2/services/llm_service.py
-
curl -L -o llm_service.py https://huggingface.co/spaces/utkarsh134/FastAPIExperience2/resolve/main/services/llm_service.py
6.23 kB
| from langchain_google_genai import ChatGoogleGenerativeAI | |
| from langchain.prompts import PromptTemplate | |
| from config.settings import get_settings | |
| def get_llm(): | |
| settings = get_settings() | |
| return ChatGoogleGenerativeAI( | |
| model=settings["llm_model"], | |
| temperature=settings["temperature"], | |
| google_api_key=settings["google_api_key"], | |
| ) | |
| def get_unified_resume_prompt(): | |
| return PromptTemplate( | |
| input_variables=["resume_text", "relevant_content", "job_role"], | |
| template='''You are a professional resume analyzer with expertise in technical recruiting. | |
| Your task is to extract both basic information and relevant work experience from the resume. | |
| RESUME CONTENT: | |
| {resume_text} | |
| MOST RELEVANT SECTIONS (semantically similar to job requirements): | |
| {relevant_content} | |
| TARGET JOB ROLE/DESCRIPTION: {job_role} | |
| TASK INSTRUCTIONS: | |
| Basic Information: | |
| 1. Extract all personally identifiable information that is explicitly stated in the text | |
| 2. For fields where information is not found, use null | |
| 3. Do not invent or infer information not present in the text | |
| 4. For education, only return the highest level completed (postgraduate > undergraduate > 12th > 10th) | |
| 5. Extract the university/institution name for the highest education qualification | |
| 6. For role, use the most recent/current position mentioned | |
| 7. Return complete values - do not truncate or summarize unnecessarily | |
| 8. Maintain exact formatting/capitalization as shown in the resume | |
| 9. Extract all contact information including email and phone number (just the primary number) | |
| 10. Look for any government ID numbers (PAN, Aadhar, Passport) that might be present | |
| Experience Analysis: | |
| 1. Create a single concise paragraph summarizing ALL relevant professional experience that directly relates to the job role | |
| 2. Focus only on experiences that explicitly demonstrate use of the exact technologies/tools required | |
| 3. If NO relevant experience is found, return null for relevant_experience | |
| 4. Provide a brief summary analyzing how well the candidate's experience matches the job role | |
| Skill Scoring: | |
| 1. Identify all technical and professional skills mentioned in the resume which are relevant to the job role provided | |
| 2. For each skill, count its occurrences: | |
| - If mentioned under projects or experience sections: 5 points per occurrence | |
| - If mentioned outside projects/experience sections: 3 points per occurrence | |
| 3. Calculate total score for each skill by summing up all occurrences | |
| 4. Include both the skill name and its calculated score | |
| HR Questions Generation: | |
| 1. Generate as many relevant interview questions based on the candidate's experience and the job role | |
| 2. For each question, provide the expected answer based on information found in the resume | |
| 3. Focus questions on: | |
| - Technical skills and their practical application | |
| - Project experiences and challenges | |
| - Role-specific competencies | |
| - Career transitions or gaps if any | |
| 4. Questions should be specific to this candidate's background | |
| 5. Answers should strictly reflect information available in the resume | |
| FORMAT YOUR RESPONSE AS A VALID JSON OBJECT WITH THIS EXACT STRUCTURE: | |
| {{ | |
| "candidate_name": "full name of the candidate", | |
| "gender": "gender if mentioned", | |
| "date_of_birth": "DOB in YYYY/MM/DD format if mentioned", | |
| "email": "email address if mentioned", | |
| "mobile_number": "primary phone number if mentioned", | |
| "address": "complete physical address if mentioned", | |
| "pan_number": "PAN number if mentioned", | |
| "aadhar_number": "Aadhar number if mentioned", | |
| "passport_number": "Passport number if mentioned", | |
| "highest_education": "most advanced completed education level, interpret from the data and return only 4 of these options : 10th, 12th, Undergraduate, PostGraduate", | |
| "university_name": "name of the university/institution where highest education was completed", | |
| "designation": "current or most recent role/position", | |
| "skills": "comma-separated list of technical and professional skills", | |
| "skill_score": [ | |
| {{"skill_name": "name of the skill", "skill_score": numerical_score}}, | |
| ... | |
| ], | |
| "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", | |
| "region": "geographical region/city of work", | |
| "relevant_experience": "single paragraph summarizing all experience relevant to the job role. If no relevant experience found,reply with a sentence describing they have no relevant experience", | |
| "experience_summary": "brief analysis of how well the experience matches the job role", | |
| "hr_questions": [ | |
| {{ | |
| "question": "relevant interview question based on resume content and job role", | |
| "answer": "expected answer based on the resume content" | |
| }}, | |
| ... | |
| ] | |
| }} | |
| IMPORTANT: | |
| - DO NOT INVENT OR ADD INFORMATION that is not in the resume | |
| - BE EXTREMELY STRICT about experience relevance | |
| - Response must be a valid JSON object | |
| - For sensitive information like Aadhar/PAN, return only if explicitly mentioned in resume | |
| - Skills should be returned as a comma-separated string (e.g. "Java, Spring Boot, Docker, AWS, PostgreSQL") | |
| - Calculate skill scores accurately based on occurrences in projects/experience (5 points) vs elsewhere (3 points) | |
| - HR questions should be relevant to both the candidate's experience and the target job role''' | |
| ) | |