robertselvam commited on
Commit
7a213a3
·
verified ·
1 Parent(s): 6fdfca2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -11
app.py CHANGED
@@ -1,9 +1,11 @@
1
  import gradio as gr
2
  import os
3
  import fitz
4
- import openai
5
  import re
6
 
 
 
7
  class ResumeAnalyser:
8
  def __init__(self):
9
  pass
@@ -33,9 +35,10 @@ class ResumeAnalyser:
33
  job_description = self.extract_text_from_file(job_description_path.name)
34
  for resume_path in resume_list_path:
35
  resume = self.extract_text_from_file(resume_path.name)
36
- response = openai.Completion.create(
37
- engine = "text-davinci-003",
38
- 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}
 
39
  **Detailed Analysis:**
40
  Introduction to say we've assessment the resume
41
  the result should be in this format:
@@ -54,13 +57,21 @@ class ResumeAnalyser:
54
  Certifications: [Pursue certifications in mention area].\n
55
  Feel free to contact us for further clarification.\n
56
  Best wishes,
57
- 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.""",
58
- temperature=0,
59
- max_tokens=1000,
60
- stop=None,
61
- )
62
- generated_text = response.choices[0].text.strip()
63
- result += generated_text + "\n-------------------------------------------------------------------------------------\n"
 
 
 
 
 
 
 
 
64
  return result
65
 
66
  def clear(self,jobDescription,resume,result_email):
 
1
  import gradio as gr
2
  import os
3
  import fitz
4
+ from openai import OpenAI
5
  import re
6
 
7
+ client = OpenAI()
8
+
9
  class ResumeAnalyser:
10
  def __init__(self):
11
  pass
 
35
  job_description = self.extract_text_from_file(job_description_path.name)
36
  for resume_path in resume_list_path:
37
  resume = self.extract_text_from_file(resume_path.name)
38
+ # Create a conversation for the OpenAI chat API
39
+ conversation = [
40
+ {"role": "system", "content": "You are a Mental Healthcare Chatbot."},
41
+ {"role": "user", "content": 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}
42
  **Detailed Analysis:**
43
  Introduction to say we've assessment the resume
44
  the result should be in this format:
 
57
  Certifications: [Pursue certifications in mention area].\n
58
  Feel free to contact us for further clarification.\n
59
  Best wishes,
60
+ 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."""}
61
+ ]
62
+
63
+ # Call OpenAI GPT-3.5-turbo
64
+ chat_completion = client.chat.completions.create(
65
+ model = "gpt-3.5-turbo",
66
+ messages = conversation,
67
+ max_tokens=300,
68
+ temperature=0
69
+ )
70
+
71
+ response = chat_completion.choices[0].message.content
72
+
73
+ result += response + "\n-------------------------------------------------------------------------------------\n"
74
+
75
  return result
76
 
77
  def clear(self,jobDescription,resume,result_email):