File size: 3,121 Bytes
a87c42c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# import os
import json
import pypdfium2 as pdfium
import google.generativeai as genai
# from dotenv import load_dotenv

# load_dotenv()
# GEMINI_API_KEY = os.getenv('GEMINI_API_KEY')


class HR_Executive:
    def __init__(self, model_n, instruction, api_key):
        genai.configure(api_key=api_key)
        self.model = genai.GenerativeModel(
            model_n,
            generation_config={"response_mime_type": "application/json"},
            system_instruction=instruction, 
        )
        
    
    def run(self, inputs:list):
        response = self.model.generate_content(inputs)
        response = json.loads(response.text)
        return response
    

system_instructions = {
    "tech_hr_system_instruction": """

    You are an experienced Technical Human Resource Manager. Your task is to review the provided resume/CV against the technical job description. 

    

    Evaluate the candidate for the job based on the provided resume/CV. And extract the candidate contact details from resume/CV also, so that further HR executive can contact to candidate. Shortlist the candidate based on provided ats score.

    

    Your evaluation should include:

    1. A percentage match between the resume and the job description.

    2. Candidate details, like Name, contact, email.

    3. Final thoughts on the candidate's suitability for the position.

    4. Shortlisted status[True or False]. True, if ats score satisfy the given ats score else False.



    Give output in below JSON schema only:

    candidate_evaluation = {

        "details": {

            "name": str,

            "contact": str,

            "email": str,

            "ats_score": int,

            "final_thoughts":str

        },

        "shortlist": boolean

    }

    """,
    "nontech_hr_system_instruction": """

    You are an experienced Non-Technical Human Resource Manager. Your task is to review the provided resume/CV against the Non-Technical job description. 



    Evaluate the candidate for the job based on the provided resume/CV. And extract the candidate contact details from resume/CV also, so that further HR executive can contact to candidate. Shortlist the candidate based on provided ats score.



    Your evaluation should include:

    1. A percentage match between the resume and the job description.

    2. Candidate details, like Name, contact, email.

    3. Final thoughts on the candidate's suitability for the position.

    4. Shortlisted status[True or False]. True, if ats score satisfy the given ats score else False.



    Give output in below JSON schema only:

    candidate_evaluation = {

        "details": {

            "name": str,

            "contact": str,

            "email": str,

            "ats_score": int,

            "final_thoughts":str

        },

        "shortlist": boolean

    }

    """
}


def pdf_2_images(pdf_path): 
    pages = pdfium.PdfDocument(pdf_path)

    images = []
    for page in enumerate(pages):
        image = page[1].render(scale=4).to_pil()
        images.append(image)
    return images