Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
import streamlit as st
|
| 3 |
import google.generativeai as genai
|
| 4 |
import os
|
|
@@ -6,50 +5,64 @@ import PyPDF2 as pdf
|
|
| 6 |
from dotenv import load_dotenv
|
| 7 |
import json
|
| 8 |
|
| 9 |
-
load_dotenv()
|
| 10 |
|
| 11 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 12 |
|
| 13 |
-
def
|
| 14 |
-
model=genai.GenerativeModel('gemini-1.5-pro')
|
| 15 |
-
response=model.generate_content(
|
| 16 |
return response.text
|
| 17 |
|
| 18 |
def input_pdf_text(uploaded_file):
|
| 19 |
-
reader=pdf.PdfReader(uploaded_file)
|
| 20 |
-
text=""
|
| 21 |
for page in range(len(reader.pages)):
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
return text
|
| 25 |
|
| 26 |
-
#Prompt Template
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
on
|
| 35 |
-
the missing keywords with high accuracy
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
| 41 |
"""
|
| 42 |
|
| 43 |
-
##
|
| 44 |
st.title("Smart ATS")
|
| 45 |
-
st.text("Improve Your Resume ATS")
|
| 46 |
-
|
| 47 |
-
|
|
|
|
| 48 |
|
| 49 |
submit = st.button("Submit")
|
| 50 |
|
| 51 |
if submit:
|
| 52 |
-
if uploaded_file is not None:
|
| 53 |
-
text=input_pdf_text(uploaded_file)
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import google.generativeai as genai
|
| 3 |
import os
|
|
|
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
import json
|
| 7 |
|
| 8 |
+
load_dotenv() ## Load all environment variables
|
| 9 |
|
| 10 |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
| 11 |
|
| 12 |
+
def get_gemini_response(input_text):
|
| 13 |
+
model = genai.GenerativeModel('gemini-1.5-pro')
|
| 14 |
+
response = model.generate_content(input_text)
|
| 15 |
return response.text
|
| 16 |
|
| 17 |
def input_pdf_text(uploaded_file):
|
| 18 |
+
reader = pdf.PdfReader(uploaded_file)
|
| 19 |
+
text = ""
|
| 20 |
for page in range(len(reader.pages)):
|
| 21 |
+
extracted_text = reader.pages[page].extract_text()
|
| 22 |
+
if extracted_text:
|
| 23 |
+
text += extracted_text
|
| 24 |
return text
|
| 25 |
|
| 26 |
+
# Prompt Template
|
| 27 |
+
input_prompt = """
|
| 28 |
+
Hey, act like a skilled and very experienced ATS (Application Tracking System)
|
| 29 |
+
with a deep understanding of tech fields such as software engineering, data science,
|
| 30 |
+
data analysis, and big data engineering. Your task is to evaluate the resume
|
| 31 |
+
based on the given job description.
|
| 32 |
+
|
| 33 |
+
You must consider that the job market is very competitive, and you should provide
|
| 34 |
+
the best assistance for improving resumes. Assign the percentage match based on JD
|
| 35 |
+
and identify the missing keywords with high accuracy.
|
| 36 |
+
|
| 37 |
+
resume: {text}
|
| 38 |
+
description: {jd}
|
| 39 |
+
|
| 40 |
+
I want the response in one single JSON string with the following structure:
|
| 41 |
+
{{"JD Match":"%", "MissingKeywords":[], "Profile Summary":""}}
|
| 42 |
"""
|
| 43 |
|
| 44 |
+
## Streamlit app
|
| 45 |
st.title("Smart ATS")
|
| 46 |
+
st.text("Improve Your Resume for ATS Systems")
|
| 47 |
+
|
| 48 |
+
jd = st.text_area("Paste the Job Description")
|
| 49 |
+
uploaded_file = st.file_uploader("Upload Your Resume", type="pdf", help="Please upload a PDF file")
|
| 50 |
|
| 51 |
submit = st.button("Submit")
|
| 52 |
|
| 53 |
if submit:
|
| 54 |
+
if uploaded_file is not None and jd:
|
| 55 |
+
text = input_pdf_text(uploaded_file)
|
| 56 |
+
formatted_prompt = input_prompt.format(text=text, jd=jd)
|
| 57 |
+
response = get_gemini_response(formatted_prompt)
|
| 58 |
+
|
| 59 |
+
# Try parsing the response as JSON
|
| 60 |
+
try:
|
| 61 |
+
parsed_response = json.loads(response)
|
| 62 |
+
st.subheader("Job Description Match: " + parsed_response["JD Match"])
|
| 63 |
+
st.write("Missing Keywords: ", parsed_response["MissingKeywords"])
|
| 64 |
+
st.write("Profile Summary: ", parsed_response["Profile Summary"])
|
| 65 |
+
except json.JSONDecodeError:
|
| 66 |
+
st.error("Error: Could not parse the response. Please check the response format.")
|
| 67 |
+
else:
|
| 68 |
+
st.warning("Please upload a resume and enter a job description.")
|