santu24 commited on
Commit
e21a71e
·
verified ·
1 Parent(s): a7d1d4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -14
app.py CHANGED
@@ -4,10 +4,8 @@ from PyPDF2 import PdfReader
4
  import base64
5
  from docx import Document
6
 
7
- # Hardcoded API key
8
  API_KEY = st.secrets["API_KEY"]
9
 
10
- # Function to extract text from PDF
11
  def extract_text_from_pdf(pdf_file):
12
  reader = PdfReader(pdf_file)
13
  text = ""
@@ -15,7 +13,6 @@ def extract_text_from_pdf(pdf_file):
15
  text += page.extract_text()
16
  return text
17
 
18
- # Function to extract text from DOCX
19
  def extract_text_from_docx(docx_file):
20
  doc = Document(docx_file)
21
  text = ""
@@ -23,7 +20,6 @@ def extract_text_from_docx(docx_file):
23
  text += para.text + "\n"
24
  return text
25
 
26
- # Function to analyze documents using the Gemini API
27
  def analyze_documents(resume_text, job_description):
28
  custom_prompt = f"""
29
  Please analyze the following resume in the context of the job description provided. Strictly check every single line in job description and analyze my resume whether there is a match exactly. Strictly maintain high ATS standards and give scores only to the correct ones. Focus on hard skills which are missing and also soft skills which are missing. Provide the following details.:
@@ -33,7 +29,7 @@ def analyze_documents(resume_text, job_description):
33
  4. Recommendations on how to add the missing keywords and improve the resume in 3-4 points with examples.
34
  Please display in the above order don't mention the numbers like 1. 2. etc and strictly follow ATS standards so that analysis will be accurate. Strictly follow the above templates omg. don't keep changing every time.
35
  Strictly follow the above things and template which has to be displayed and don't keep changing again and again. Don't fucking change the template from above.
36
- Title should be Resume analysis and maintain the same title for all. Also if someone uploads the same unchanged resume twice, keep in mind to give the same results, some might do to test you. so if someone does that just display same results. Display new ones only if they have changed their resume according to your suggestions or at least few changes.
37
  Job Description: {job_description}
38
 
39
  Resume: {resume_text}
@@ -49,7 +45,6 @@ def analyze_documents(resume_text, job_description):
49
  response = requests.post(url, headers=headers, json=data)
50
  return response.json()
51
 
52
- # Function to rephrase text using the Gemini API
53
  def rephrase_text(text):
54
  custom_prompt = f"""
55
  Please rephrase the following text according to ATS standards, including quantifiable measures and improvements where possible, also maintain precise and concise points which will pass ATS screening:
@@ -67,7 +62,6 @@ def rephrase_text(text):
67
  response = requests.post(url, headers=headers, json=data)
68
  return response.json()
69
 
70
- # Function to display PDF or DOCX in Streamlit
71
  def display_resume(file):
72
  file_type = file.name.split('.')[-1].lower()
73
  if file_type == 'pdf':
@@ -81,14 +75,12 @@ def display_resume(file):
81
  text = ""
82
  for para in doc.paragraphs:
83
  text += para.text + "\n"
84
- st.text_area("Resume Content", text, height=400)
85
  else:
86
  st.error("Unsupported file type. Please upload a PDF or DOCX file.")
87
 
88
- # Streamlit application
89
  st.set_page_config(page_title="ATS Resume Evaluation System", layout="wide")
90
 
91
- # Sidebar for navigation
92
  st.sidebar.title("Navigation")
93
  page = st.sidebar.radio("Go to", ["Resume Analyzer", "Magic Write", "ATS Templates"])
94
 
@@ -114,17 +106,14 @@ if page == "Resume Analyzer":
114
  resume_text = extract_text_from_docx(resume)
115
  analysis = analyze_documents(resume_text, job_description)
116
 
117
- # Extracting and displaying the content
118
  if "candidates" in analysis:
119
  for candidate in analysis["candidates"]:
120
  if "content" in candidate and "parts" in candidate["content"]:
121
  for part in candidate["content"]["parts"]:
122
  response_text = part["text"]
123
 
124
- # Display the structured response directly
125
  st.markdown(response_text)
126
 
127
- # Extract match percentage from response text
128
  lines = response_text.split("\n")
129
  for line in lines:
130
  if "match percentage" in line.lower():
@@ -133,7 +122,6 @@ if page == "Resume Analyzer":
133
  match_percentage = int(match_percentage)
134
  break
135
 
136
- # Display the match percentage as a meter
137
  st.write(f"Your Resume Match Percentage: {match_percentage}%")
138
  st.progress(match_percentage)
139
 
 
4
  import base64
5
  from docx import Document
6
 
 
7
  API_KEY = st.secrets["API_KEY"]
8
 
 
9
  def extract_text_from_pdf(pdf_file):
10
  reader = PdfReader(pdf_file)
11
  text = ""
 
13
  text += page.extract_text()
14
  return text
15
 
 
16
  def extract_text_from_docx(docx_file):
17
  doc = Document(docx_file)
18
  text = ""
 
20
  text += para.text + "\n"
21
  return text
22
 
 
23
  def analyze_documents(resume_text, job_description):
24
  custom_prompt = f"""
25
  Please analyze the following resume in the context of the job description provided. Strictly check every single line in job description and analyze my resume whether there is a match exactly. Strictly maintain high ATS standards and give scores only to the correct ones. Focus on hard skills which are missing and also soft skills which are missing. Provide the following details.:
 
29
  4. Recommendations on how to add the missing keywords and improve the resume in 3-4 points with examples.
30
  Please display in the above order don't mention the numbers like 1. 2. etc and strictly follow ATS standards so that analysis will be accurate. Strictly follow the above templates omg. don't keep changing every time.
31
  Strictly follow the above things and template which has to be displayed and don't keep changing again and again. Don't fucking change the template from above.
32
+ Title should be Resume analysis and maintain the same title for all. Also if someone uploads the same unchanged resume twice, keep in mind to give the same results. Display new ones only if they have changed their resume according to your suggestions or at least few changes.
33
  Job Description: {job_description}
34
 
35
  Resume: {resume_text}
 
45
  response = requests.post(url, headers=headers, json=data)
46
  return response.json()
47
 
 
48
  def rephrase_text(text):
49
  custom_prompt = f"""
50
  Please rephrase the following text according to ATS standards, including quantifiable measures and improvements where possible, also maintain precise and concise points which will pass ATS screening:
 
62
  response = requests.post(url, headers=headers, json=data)
63
  return response.json()
64
 
 
65
  def display_resume(file):
66
  file_type = file.name.split('.')[-1].lower()
67
  if file_type == 'pdf':
 
75
  text = ""
76
  for para in doc.paragraphs:
77
  text += para.text + "\n"
78
+ st.text_area("Parsed Resume Content", text, height=400)
79
  else:
80
  st.error("Unsupported file type. Please upload a PDF or DOCX file.")
81
 
 
82
  st.set_page_config(page_title="ATS Resume Evaluation System", layout="wide")
83
 
 
84
  st.sidebar.title("Navigation")
85
  page = st.sidebar.radio("Go to", ["Resume Analyzer", "Magic Write", "ATS Templates"])
86
 
 
106
  resume_text = extract_text_from_docx(resume)
107
  analysis = analyze_documents(resume_text, job_description)
108
 
 
109
  if "candidates" in analysis:
110
  for candidate in analysis["candidates"]:
111
  if "content" in candidate and "parts" in candidate["content"]:
112
  for part in candidate["content"]["parts"]:
113
  response_text = part["text"]
114
 
 
115
  st.markdown(response_text)
116
 
 
117
  lines = response_text.split("\n")
118
  for line in lines:
119
  if "match percentage" in line.lower():
 
122
  match_percentage = int(match_percentage)
123
  break
124
 
 
125
  st.write(f"Your Resume Match Percentage: {match_percentage}%")
126
  st.progress(match_percentage)
127