Resume_Analyser / app.py
Samay42's picture
Update app.py
c2cd46e verified
Raw
History Blame Contribute Delete
2.31 kB
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.
""")