File size: 5,459 Bytes
3c16641
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3cd7a3
 
3c16641
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import gradio as gr
import os
import fitz
import openai
import re

class ResumeAnalyser:
    def __init__(self):
        pass
    def extract_text_from_file(self, file_path):
        # Get the file extension
        file_extension = os.path.splitext(file_path)[1]

        if file_extension == '.pdf':
            # Use PyMuPDF (fitz) for PDF text extraction
            doc = fitz.open(file_path)
            extracted_text = ""
            for page in doc:
                extracted_text += page.get_text()
            doc.close()
            return extracted_text

        elif file_extension == '.txt':
            with open(file_path, 'r') as file:
                # Just read the entire contents of the text file
                return file.read()
        else:
            return "Unsupported file type"
    
    def responce_from_ai(self,job_description_path, resume_list_path):
    
      result = ""
      job_description = self.extract_text_from_file(job_description_path.name)
      for resume_path in resume_list_path:
          resume = self.extract_text_from_file(resume_path.name)
          response = openai.Completion.create(
              engine = "text-davinci-003",
              prompt = f"""Given the job description and the resume, assess the matching percentage to 100 and if 100 percentage not matched mention the remaining percentage with reason. **Job Description:**{job_description}**Resume:**{resume}
              **Detailed Analysis:**
              Introduction to say we've assessment the resume
                      the result should be in this format:
                      Matched Percentage: Precisely [get matching percentage between job description and resume]%.\n
                      Qualification Matching Percentage: [matching percentage between job description and resume qualifications].\n
                      Skills Matching Percentage: [matching percentage between job description and resume skills].\n
                      Experience Matching Percentage: [matching percentage between job description and resume experience].\n
                      Reason            : [Reasons for why this resume matched and not matched.].\n
                      Skills To Improve : [Mention the skills to improve for the candidate according to the given job description. If there are no matches, simply say N/A.].\n
                      Keywords          : [Return the matched keywords from resume and job_description. If there are no matches, simply say N/A.]\n
                      Company : [Extracted company name from job description].\n
                      Irrevelant: [mention the irrevelant skills and expericence]\n
                      Recommend Course:  [mention specific course to recommend the candidate for job description needs].\n
                      Experience: [mention specific experience to recommend the candidate for job description needs].\n
                      Tailor Your Application: [Emphasize relevant areas].\n
                      Certifications: [Pursue certifications in mention area].\n
                      Feel free to contact us for further clarification.\n
                      Best wishes,
              Your job is to write a proper E-Mail to the candidate from the organization with the job role, the candidate's name, organization name, and the body of this E-Mail should be in the above format.""",
              temperature=0,
              max_tokens=1000,
              stop=None,
          )
          generated_text = response.choices[0].text.strip()
          result += generated_text + "\n-------------------------------------------------------------------------------------\n"
      return result
    
    def clear(self,jobDescription,resume,result_email):
      jobDescription = None
      resume = None
      result_email = None
      return jobDescription, resume, result_email    
    
    def gradio_interface(self):
      with gr.Blocks(css="style.css",theme='karthikeyan-adople/hudsonhayes-gray') as app:
            gr.HTML("""<center class="darkblue" style='background-color:rgb(0,1,36); text-align:center;padding:25px;'><center>
            <h1 class ="center" style="color:#fff">ADOPLE AI</h1></center>
              <br><h1 style="color:#fff">Candidate Assessment and Communication</h1></center>""")
            with gr.Row(elem_id="col-container"):
              with gr.Column(scale=0.55, min_width=150, ):
                jobDescription = gr.File(label="Job Description", file_types = [".pdf",".txt"])
              with gr.Column(scale=0.55, min_width=150):
                resume = gr.File(label="Resume", file_types = [".pdf",".txt"] , file_count="multiple")
            with gr.Row(elem_id="col-container"):
              with gr.Column(scale=0.80, min_width=150):
                analyse = gr.Button("Analyse")
              with gr.Column(scale=0.20, min_width=150):
                clear_btn = gr.ClearButton()                  
            with gr.Row(elem_id="col-container"):
              with gr.Column(scale=1.0, min_width=150):
                result_email = gr.Textbox(label="E-mail", lines=10)
    
            analyse.click(self.responce_from_ai, [jobDescription, resume], [result_email])
            clear_btn.click(self.clear,[jobDescription,resume,result_email],[jobDescription,resume,result_email] )
    
      app.launch()

if __name__ == "__main__":
    resume = ResumeAnalyser()
    answer = resume.gradio_interface()