File size: 2,310 Bytes
c2cd46e
63c0ac7
c2cd46e
63c0ac7
 
c2cd46e
63c0ac7
c2cd46e
 
 
63c0ac7
c2cd46e
 
 
 
 
 
 
 
 
 
 
 
63c0ac7
 
c2cd46e
 
63c0ac7
 
 
c2cd46e
 
63c0ac7
 
 
 
 
 
 
 
 
c2cd46e
 
 
 
63c0ac7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import streamlit as st
import google.generativeai as genai
import pandas as pd
from io import StringIO
import fitz  # PyMuPDF

# Configure Google Generative AI
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
model = genai.GenerativeModel('gemini-1.5-flash')

def extract_text_from_pdf(file):
    """Extract text from PDF."""
    text = ""
    doc = fitz.open(stream=file.read(), filetype="pdf")
    for page in doc:
        text += page.get_text()
    return text

def get_gemini_response(prompt):
    """Function to load Google Gemini model and provide queries as response."""
    response = model.generate_content([prompt])
    return response[0]['text']  # Adjust this line based on actual response structure

def extract_skills(resume_text):
    prompt = f"Extract the skills from the following resume:\n\n{resume_text}"
    skills = get_gemini_response(prompt)
    return skills

def match_job_description(resume_text, job_description):
    prompt = f"Compare the following resume with the job description and provide a match score:\n\nResume:\n{resume_text}\n\nJob Description:\n{job_description}"
    score = get_gemini_response(prompt)
    return score

# Streamlit application layout
st.title('Resume Analyzer for Recruiters')

st.header('Upload Resume')
uploaded_file = st.file_uploader('Choose a file', type=['pdf', 'docx', 'txt'])

if uploaded_file is not None:
    if uploaded_file.type == "application/pdf":
        resume_text = extract_text_from_pdf(uploaded_file)
    else:
        resume_text = uploaded_file.getvalue().decode("utf-8")

    st.subheader('Resume Text')
    st.write(resume_text)

    st.subheader('Extract Skills')
    if st.button('Extract Skills'):
        skills = extract_skills(resume_text)
        st.write('Skills:', skills)

    st.subheader('Match with Job Description')
    job_description = st.text_area('Enter Job Description')
    if st.button('Match'):
        score = match_job_description(resume_text, job_description)
        st.write('Match Score:', score)

st.sidebar.header('About')
st.sidebar.write("""
This application uses the Google Generative AI Gemini-pro model to analyze resumes, extract key skills, and match resumes with job descriptions. It helps recruiters quickly evaluate candidates and streamline the recruitment process.
""")