File size: 2,488 Bytes
d16025d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import streamlit as st
from huggingface_hub import InferenceClient
from dotenv import load_dotenv
import os
import PyPDF2 as pdf

# Load .env file
load_dotenv()
api_key = os.getenv("HUGGINGFACEHUB_API_TOKEN")

# Hugging Face model
MODEL = "nvidia/Llama-3_1-Nemotron-Ultra-253B-v1"

# Set up page
st.set_page_config(page_title="JD Matcher by Jishnu Setia", page_icon="πŸ“„")
st.title("πŸ“Œ Job Description Matcher")
st.text("Find out if your resume matches the job you're targeting!")

# Input fields
jd = st.text_area("πŸ“ Paste the Job Description here:")
uploaded_file = st.file_uploader("πŸ“Ž Upload Your Resume (PDF only):", type="pdf")

submit = st.button("πŸš€ Submit")

# Function to read PDF content
def input_pdf_text(uploaded_file):
    reader = pdf.PdfReader(uploaded_file)
    text = ""
    for page in reader.pages:
        text += page.extract_text()
    return text

# Prompt template
system_prompt = {
    "role": "system",
    "content": (
        "You are a highly experienced ATS (Applicant Tracking System). Evaluate the resume based on the given job description. "
        "Be strict, accurate, and helpful. Job market is very competitive. Return your response in this format:\n\n"
        "1. JD Match Percentage: \"%\"\n"
        "2. Matching Feedback: (e.g., 'Great match!' or 'Needs improvement')\n"
        "3. Missing Keywords: [list]\n"
        "4. Tips to Improve the Resume:"
    )
}

# When submit is clicked
if submit:
    if uploaded_file and jd:
        with st.spinner("Analyzing your resume..."):
            resume_text = input_pdf_text(uploaded_file)

            # Prepare context
            context = [
                system_prompt,
                {"role": "user", "content": f"Resume:\n{resume_text}\n\nJob Description:\n{jd}"}
            ]

            try:
                client = InferenceClient(
                    model=MODEL,
                    provider="nebius",
                    api_key=api_key
                )

                completion = client.chat.completions.create(
                    model=MODEL,
                    messages=context,
                    max_tokens=2048,
                )

                response = completion.choices[0].message.content
                st.subheader("πŸ“Š ATS Evaluation Result")
                st.markdown(response)

            except Exception as e:
                st.error(f"❌ Error: {e}")
    else:
        st.warning("Please upload a resume and paste a job description!")