Vaishvik1618 commited on
Commit
bf866a6
·
verified ·
1 Parent(s): edc27a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +110 -140
app.py CHANGED
@@ -1,140 +1,110 @@
1
- import io
2
-
3
- # from dotenv import load_dotenv
4
- #
5
- # load_dotenv()
6
-
7
- import streamlit as st
8
- import os
9
- from PIL import Image
10
- import pdf2image
11
- import google.generativeai as genai
12
- import base64
13
-
14
-
15
-
16
- genai.configure(api_key="AIzaSyBqPmsZAJrCsXme9wJBx9o4K71M9c1qzy8")
17
-
18
- def ai_output(input, pdf_content, prompt):
19
- model = genai.GenerativeModel('gemini-1.5-flash')
20
- response = model.generate_content([input, pdf_content[0], prompt])
21
- return response.text
22
-
23
- def ai_ans(input,prompt):
24
- model = genai.GenerativeModel('gemini-1.5-flash')
25
- response = model.generate_content([input,prompt])
26
- return response.text
27
-
28
- def input_pdf_setup(uploaded_file):
29
- if uploaded_file is not None:
30
- images = pdf2image.convert_from_bytes(uploaded_file.read())
31
- first_page = images[0]
32
- img_byte_arr = io.BytesIO()
33
- first_page.save(img_byte_arr, format='JPEG')
34
- img_byte_arr = img_byte_arr.getvalue()
35
-
36
- pdf_parts=[
37
- {
38
- "mime_type": "image/jpeg",
39
- "data": base64.b64encode(img_byte_arr).decode() # encode to base64
40
- }
41
- ]
42
- return pdf_parts
43
- else:
44
- raise FileNotFoundError("No file uploaded")
45
-
46
- st.set_page_config(page_title="ATS resume Expert")
47
- st.header("HARIMAY ATS Tracking System")
48
- input_text = st.text_area("job description: ", key = "input")
49
- uploaded_file = st.file_uploader("Upload your resume (PDF)....", type=["pdf"])
50
- job_role = st.text_area("Enter job role", key="job")
51
-
52
-
53
-
54
- if uploaded_file is not None:
55
- st.write("pdf file uploaded successfully")
56
-
57
- submit1 = st.button("Tell me about the Resume")
58
-
59
- submit2 = st.button("Percentage Match")
60
-
61
- submit3 = st.button("Job skills")
62
-
63
-
64
-
65
- input_prompt1 = """
66
- You are an experienced Technical Human Resource Manager,your task is to review the provided resume against the job description.
67
- Please share your professional evaluation on whether the candidate's profile aligns with the role.
68
- Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
69
- """
70
-
71
- input_prompt2 = """
72
- You are an skilled ATS (Applicant Tracking System) scanner with a deep understanding of ATS functionality,
73
- your task is to evaluate the resume against the provided job description. give me the percentage of match if the resume matches
74
- the job description. First the output should come as percentage and then keywords missing and last final thoughts.
75
- """
76
-
77
- input_prompt3 = """
78
- You are an advanced career advisor and job market expert with deep insights into various industries. When given a job role, your task is to identify and list the key skills and qualifications that are most commonly required for success in that position. Please provide a structured output that includes:
79
-
80
- 1. A detailed list of technical and hard skills.
81
- 2. A summary of soft skills crucial for the role.
82
- 3. Recommended educational qualifications and certifications associated with the job.
83
- """
84
-
85
- if submit1:
86
- if uploaded_file is not None:
87
- pdf_content = input_pdf_setup(uploaded_file)
88
- response = ai_output(input_text,pdf_content,input_prompt1)
89
- st.subheader("The Response is...")
90
- st.write(response)
91
- else:
92
- st.write("Please uploaded the Resunme.")
93
- elif submit2:
94
- if uploaded_file is not None:
95
- pdf_content = input_pdf_setup(uploaded_file)
96
- response = ai_output(input_text,pdf_content,input_prompt2)
97
- st.subheader("The Response is...")
98
- st.write(response)
99
- else:
100
- st.write("Please uploaded the Resunme.")
101
-
102
- elif submit3:
103
- response = ai_ans(job_role,input_prompt3)
104
- st.subheader("The Response is...")
105
- st.write(response)
106
-
107
- with st.expander("Generate Cover Letter"):
108
- applicant_name = st.text_input("Enter Your Name")
109
- contact_info = st.text_input("Enter Your Contact Information (Email, Phone)")
110
- company_name = st.text_input("Enter the Company Name")
111
- hiring_manager_name = st.text_input("Enter the Hiring Manager's Name (optional)")
112
- job_role = st.text_area("Enter job role")
113
-
114
- if uploaded_file is not None:
115
- pdf_content = input_pdf_setup(uploaded_file)
116
- cover_letter_button = st.button("Generate Cover Letter")
117
- if not applicant_name:
118
- st.write("Warning: Applicant's Name is missing.")
119
- if not contact_info:
120
- st.write("Warning: Contact Information is missing.")
121
-
122
- if cover_letter_button:
123
- # Define the input prompt for the cover letter
124
- input_prompt_cover_letter = f"""
125
- You are an expert cover letter writer. Generate a tailored cover letter using the following details:
126
-
127
- Applicant's Name: {applicant_name}
128
- Contact Information: {contact_info}
129
- Company Name: {company_name}
130
- Hiring Manager's Name: {hiring_manager_name}
131
- Job Role/Position Name: {job_role}
132
-
133
- The cover letter should include an engaging introduction, highlight relevant skills and experiences,
134
- and conclude with a strong closing statement expressing enthusiasm for the role.
135
- """
136
- cover_letter_response = ai_output(input_text, pdf_content, input_prompt_cover_letter)
137
- st.subheader("Generated Cover Letter:")
138
- st.write(cover_letter_response)
139
- else:
140
- st.write("Please upload the Resume to generate a cover letter.")
 
1
+ import streamlit as st
2
+ import fitz # PyMuPDF
3
+ import google.generativeai as genai
4
+
5
+ # Configure the Generative AI model
6
+ genai.configure(api_key="AIzaSyBqPmsZAJrCsXme9wJBx9o4K71M9c1qzy8")
7
+
8
+ def ai_output(input_text, pdf_text, prompt):
9
+ model = genai.GenerativeModel('gemini-1.5-flash')
10
+ combined_input = f"{input_text}\n\n{pdf_text}\n\n{prompt}"
11
+ response = model.generate_content(combined_input)
12
+ return response.text
13
+
14
+ def ai_ans(input_text, prompt):
15
+ model = genai.GenerativeModel('gemini-1.5-flash')
16
+ combined_input = f"{input_text}\n\n{prompt}"
17
+ response = model.generate_content(combined_input)
18
+ return response.text
19
+
20
+ def input_pdf_setup(uploaded_file):
21
+ if uploaded_file is not None:
22
+ pdf_document = fitz.open(stream=uploaded_file.read(), filetype="pdf")
23
+ text = ""
24
+ for page_num in range(len(pdf_document)):
25
+ page = pdf_document.load_page(page_num)
26
+ text += page.get_text()
27
+ pdf_document.close()
28
+ return text
29
+ else:
30
+ raise FileNotFoundError("No file uploaded")
31
+
32
+ st.set_page_config(page_title="ATS Resume Expert")
33
+ st.header("HARIMAY ATS Tracking System")
34
+
35
+ input_text = st.text_area("Job Description:", key="input")
36
+ uploaded_file = st.file_uploader("Upload your resume (PDF)...", type=["pdf"])
37
+ job_role = st.text_input("Enter Job Role", key="job")
38
+
39
+ if uploaded_file is not None:
40
+ pdf_text = input_pdf_setup(uploaded_file)
41
+ st.write("PDF file uploaded and processed successfully.")
42
+ else:
43
+ pdf_text = ""
44
+ st.write("Please upload the resume.")
45
+
46
+ submit1 = st.button("Tell me about the Resume")
47
+ submit2 = st.button("Percentage Match")
48
+ submit3 = st.button("Job Skills")
49
+ submit4 = st.button("Missing Keywords")
50
+
51
+ input_prompt1 = """
52
+ You are an experienced Technical Human Resource Manager. Your task is to review the provided resume against the job description.
53
+ Please share your professional evaluation on whether the candidate's profile aligns with the role.
54
+ Highlight the strengths and weaknesses of the applicant in relation to the specified job requirements.
55
+ """
56
+
57
+ input_prompt2 = """
58
+ You are a skilled ATS (Applicant Tracking System) scanner with a deep understanding of ATS functionality.
59
+ Your task is to evaluate the resume against the provided job description. Provide the percentage match if the resume aligns
60
+ with the job description. First, present the output as a percentage, then list missing keywords, and finally, offer your thoughts.
61
+ """
62
+
63
+ input_prompt3 = """
64
+ You are an advanced career advisor and job market expert with deep insights into various industries. When given a job role, your task is to identify and list the key skills and qualifications that are most commonly required for success in that position. Please provide a structured output that includes:
65
+
66
+ 1. A detailed list of technical and hard skills.
67
+ 2. A summary of soft skills crucial for the role.
68
+ 3. Recommended educational qualifications and certifications associated with the job.
69
+ """
70
+
71
+ input_prompt4 = """
72
+ You are an expert in resume optimization and keyword integration for job applications. I am providing my resume content along with a job description. Your task is to analyze the resume and identify any important keywords or skills from the job description that are missing in my resume. For each missing keyword or skill, provide the following:
73
+
74
+ 1.A clear explanation of all the missing keyword or skill and why it is important for the role.
75
+ 2.A detailed suggestion for a sentence or bullet point that can be added to the resume to include the missing keyword.
76
+ 3.Guidance on where in the resume (e.g., Professional Experience, Skills, Education, Projects) the new content should be inserted for the best impact.
77
+ Ensure that the suggestions are tailored to the context of my existing resume, maintaining a natural flow and relevance to my career background
78
+ and also tell that you experience is less that what this job is expected
79
+
80
+ also get the list of missing keywords
81
+
82
+ and tell me why I would not select for an interview for this position according to my resume
83
+
84
+ """
85
+
86
+ if submit1:
87
+ if pdf_text:
88
+ response = ai_output(input_text, pdf_text, input_prompt1)
89
+ st.subheader("The Response is:")
90
+ st.write(response)
91
+ else:
92
+ st.write("Please upload the resume.")
93
+ elif submit2:
94
+ if pdf_text:
95
+ response = ai_output(input_text, pdf_text, input_prompt2)
96
+ st.subheader("The Response is:")
97
+ st.write(response)
98
+ else:
99
+ st.write("Please upload the resume.")
100
+ elif submit3:
101
+ response = ai_ans(job_role, input_prompt3)
102
+ st.subheader("The Response is:")
103
+ st.write(response)
104
+ elif submit4:
105
+ if pdf_text:
106
+ response = ai_output(input_text, pdf_text, input_prompt4)
107
+ st.subheader("Missing things which need to be present in your resume:")
108
+ st.write(response)
109
+
110
+