Spaces:
Running
Running
rajeshthangaraj1
commited on
Commit
•
b4ab766
1
Parent(s):
dc22094
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import google.generativeai as genai
|
3 |
+
import os
|
4 |
+
import PyPDF2 as pdf
|
5 |
+
from dotenv import load_dotenv
|
6 |
+
|
7 |
+
load_dotenv()
|
8 |
+
genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))
|
9 |
+
|
10 |
+
|
11 |
+
def get_gemeni_response(input_text):
|
12 |
+
model = genai.GenerativeModel('gemini-pro')
|
13 |
+
response = model.generate_content(input_text)
|
14 |
+
return response.text
|
15 |
+
|
16 |
+
|
17 |
+
def input_pdf_text(upload_file):
|
18 |
+
reader = pdf.PdfReader(upload_file)
|
19 |
+
text = ""
|
20 |
+
for page in range(len(reader.pages)):
|
21 |
+
page_text = reader.pages[page].extract_text()
|
22 |
+
text += str(page_text)
|
23 |
+
return text
|
24 |
+
|
25 |
+
|
26 |
+
# Prompt engineering
|
27 |
+
input_prompt = """
|
28 |
+
hey Act like a skilled or very experienced ATS (Application Tracking System) with a deep understanding of tech field, software engineering,
|
29 |
+
data science, data analytics, and big data engineering. Your task is to evaluate the resume based on the given job description. You must
|
30 |
+
consider the job market is very competitive and provide the best assistance for improving the resume. Assign the percentage
|
31 |
+
Matching based on JD (Job Description) and the missing keywords with high accuracy.
|
32 |
+
resume: {text}
|
33 |
+
description: {jd}
|
34 |
+
|
35 |
+
I want the response in a structured JSON format like this:
|
36 |
+
{{"JD Match":"%", "MissingKeywords":[], "Profile Summary":""}}
|
37 |
+
"""
|
38 |
+
|
39 |
+
# Streamlit app setup
|
40 |
+
st.title('Smart ATS')
|
41 |
+
st.text("Improve your Resume ATS")
|
42 |
+
jd = st.text_area("Paste the Job Description")
|
43 |
+
uploaded_file = st.file_uploader("Upload your Resume", type="pdf", help="Please upload your resume in PDF format")
|
44 |
+
submit = st.button("Submit")
|
45 |
+
|
46 |
+
if submit:
|
47 |
+
if uploaded_file is not None:
|
48 |
+
text = input_pdf_text(uploaded_file)
|
49 |
+
response = get_gemeni_response(input_prompt.format(text=text, jd=jd))
|
50 |
+
|
51 |
+
try:
|
52 |
+
# Parse the response into a dictionary
|
53 |
+
response_dict = eval(response) # Be cautious with eval; use safer alternatives if possible
|
54 |
+
|
55 |
+
# Display structured output
|
56 |
+
st.subheader("Job Description Match")
|
57 |
+
st.write(f"{response_dict['JD Match']}")
|
58 |
+
|
59 |
+
st.subheader("Missing Keywords")
|
60 |
+
st.write(", ".join(response_dict["MissingKeywords"]))
|
61 |
+
|
62 |
+
st.subheader("Profile Summary")
|
63 |
+
st.text(response_dict["Profile Summary"])
|
64 |
+
|
65 |
+
except Exception as e:
|
66 |
+
st.error("Error parsing response. Check the response format.")
|
67 |
+
st.write(response) # Display raw response for debugging
|
68 |
+
else:
|
69 |
+
st.warning("Please upload your resume.")
|