File size: 1,599 Bytes
9bec5f7
 
 
6455aa3
9bec5f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ad0301
9bec5f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2ad0301
9bec5f7
 
 
 
 
 
 
 
 
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
import streamlit as st
import PyPDF2
import google.generativeai as genai
import os

genai.configure(api_key=os.environ.get("Google_API_KEY"))
model = genai.GenerativeModel('gemini-1.5-flash')

def extract_text_from_pdf(pdf_file):
    reader = PyPDF2.PdfReader(pdf_file)
    text = ''
    for page_num in range(len(reader.pages)):
        page = reader.pages[page_num]
        text += page.extract_text()
    return text

def check_cv_match(cv_text, job_description):
    prompt = (
        f"You are an AI expert assisting with recruitment. "
        f"Compare the following resume with the job description and determine if the resume matches the job requirements. "
        f"Provide a brief analysis and a match percentage:\n\n"
        f"Job Description: {job_description}\n\n"
        f"Resume: {cv_text}\n\n"
        f"Give a score from 0% to 100% indicating how well the resume matches the job."
    )
    
    response = model.generate_content([prompt])
    return response.text


st.title("CV and Job Description Matcher")

uploaded_cv = st.file_uploader("Upload CV (PDF format)", type="pdf")

if uploaded_cv is not None:
    cv_text = extract_text_from_pdf(uploaded_cv)
    st.text_area("Extracted CV Text", value=cv_text, height=300)


job_description = st.text_area("Enter the Job Description", height=300)

if st.button("Check Match"):
    if uploaded_cv and job_description:
        match_result = check_cv_match(cv_text, job_description)
        st.write("Match Analysis:")
        st.write(match_result)
    else:
        st.error("Please upload a CV and enter the job description.")