Spaces:
Sleeping
Sleeping
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.") | |