Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from huggingface_hub import InferenceClient
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
import os
|
| 5 |
+
import PyPDF2 as pdf
|
| 6 |
+
|
| 7 |
+
# Load .env file
|
| 8 |
+
load_dotenv()
|
| 9 |
+
api_key = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 10 |
+
|
| 11 |
+
# Hugging Face model
|
| 12 |
+
MODEL = "nvidia/Llama-3_1-Nemotron-Ultra-253B-v1"
|
| 13 |
+
|
| 14 |
+
# Set up page
|
| 15 |
+
st.set_page_config(page_title="JD Matcher by Jishnu Setia", page_icon="π")
|
| 16 |
+
st.title("π Job Description Matcher")
|
| 17 |
+
st.text("Find out if your resume matches the job you're targeting!")
|
| 18 |
+
|
| 19 |
+
# Input fields
|
| 20 |
+
jd = st.text_area("π Paste the Job Description here:")
|
| 21 |
+
uploaded_file = st.file_uploader("π Upload Your Resume (PDF only):", type="pdf")
|
| 22 |
+
|
| 23 |
+
submit = st.button("π Submit")
|
| 24 |
+
|
| 25 |
+
# Function to read PDF content
|
| 26 |
+
def input_pdf_text(uploaded_file):
|
| 27 |
+
reader = pdf.PdfReader(uploaded_file)
|
| 28 |
+
text = ""
|
| 29 |
+
for page in reader.pages:
|
| 30 |
+
text += page.extract_text()
|
| 31 |
+
return text
|
| 32 |
+
|
| 33 |
+
# Prompt template
|
| 34 |
+
system_prompt = {
|
| 35 |
+
"role": "system",
|
| 36 |
+
"content": (
|
| 37 |
+
"You are a highly experienced ATS (Applicant Tracking System). Evaluate the resume based on the given job description. "
|
| 38 |
+
"Be strict, accurate, and helpful. Job market is very competitive. Return your response in this format:\n\n"
|
| 39 |
+
"1. JD Match Percentage: \"%\"\n"
|
| 40 |
+
"2. Matching Feedback: (e.g., 'Great match!' or 'Needs improvement')\n"
|
| 41 |
+
"3. Missing Keywords: [list]\n"
|
| 42 |
+
"4. Tips to Improve the Resume:"
|
| 43 |
+
)
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
# When submit is clicked
|
| 47 |
+
if submit:
|
| 48 |
+
if uploaded_file and jd:
|
| 49 |
+
with st.spinner("Analyzing your resume..."):
|
| 50 |
+
resume_text = input_pdf_text(uploaded_file)
|
| 51 |
+
|
| 52 |
+
# Prepare context
|
| 53 |
+
context = [
|
| 54 |
+
system_prompt,
|
| 55 |
+
{"role": "user", "content": f"Resume:\n{resume_text}\n\nJob Description:\n{jd}"}
|
| 56 |
+
]
|
| 57 |
+
|
| 58 |
+
try:
|
| 59 |
+
client = InferenceClient(
|
| 60 |
+
model=MODEL,
|
| 61 |
+
provider="nebius",
|
| 62 |
+
api_key=api_key
|
| 63 |
+
)
|
| 64 |
+
|
| 65 |
+
completion = client.chat.completions.create(
|
| 66 |
+
model=MODEL,
|
| 67 |
+
messages=context,
|
| 68 |
+
max_tokens=2048,
|
| 69 |
+
)
|
| 70 |
+
|
| 71 |
+
response = completion.choices[0].message.content
|
| 72 |
+
st.subheader("π ATS Evaluation Result")
|
| 73 |
+
st.markdown(response)
|
| 74 |
+
|
| 75 |
+
except Exception as e:
|
| 76 |
+
st.error(f"β Error: {e}")
|
| 77 |
+
else:
|
| 78 |
+
st.warning("Please upload a resume and paste a job description!")
|