-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
81 lines (68 loc) · 2.74 KB
/
app.py
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
80
81
import streamlit as st
import google.generativeai as genai
import os
import PyPDF2 as pdf
from dotenv import load_dotenv
import json
# Load environment variables
load_dotenv()
# Configure Streamlit page settings
st.set_page_config(
page_title="Smart ATS",
page_icon="👨💼",
layout="centered",
)
# Sidebar to input Google API Key
st.sidebar.title("Smart ATS Configuration")
API_KEY = st.sidebar.text_input("Enter your Google API Key", type="password")
st.sidebar.subheader("Don't have a Google API Key?")
st.sidebar.write("Visit [Google Makersuite](https://makersuite.google.com/app/apikey) and log in with your Google account. Then click on 'Create API Key'.")
# Check if API key is provided
if not API_KEY:
st.error("Please enter your Google API Key.")
st.stop()
# Function to configure Gemini AI model with the provided API key
def configure_gemini_api(api_key):
genai.configure(api_key=api_key)
# Configure Gemini AI model with the provided API key
configure_gemini_api(API_KEY)
# Function to get response from Gemini AI
def get_gemini_response(input):
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content(input)
return response.text
# Function to extract text from uploaded PDF file
def input_pdf_text(uploaded_file):
reader = pdf.PdfReader(uploaded_file)
text = ""
for page in range(len(reader.pages)):
page = reader.pages[page]
text += str(page.extract_text())
return text
# Prompt Template
input_prompt = """
Hey Act Like a skilled or very experienced ATS (Application Tracking System)
with a deep understanding of the tech field, software engineering, data science, data analyst
and big data engineering. Your task is to evaluate the resume based on the given job description.
You must consider the job market is very competitive and you should provide the
best assistance for improving the resumes. Assign the percentage Matching based
on JD and the missing keywords with high accuracy.
resume:{text}
description:{jd}
I want the response in one single string having the structure
{{"JD Match":"%","MissingKeywords":[],"Profile Summary":""}}
"""
## Streamlit app
st.title("Resume Matcher ATS")
st.markdown("Made by 😎 [Hardik](https://www.linkedin.com/in/hardikjp/)")
jd = st.text_area("Paste the Job Description")
uploaded_file = st.file_uploader("Upload Your Resume", type="pdf", help="Please upload the PDF")
submit = st.button("Submit")
if submit:
if uploaded_file is not None:
text = input_pdf_text(uploaded_file)
response = get_gemini_response(input_prompt.format(text=text, jd=jd))
st.subheader("Response:")
parsed_response = json.loads(response)
for key, value in parsed_response.items():
st.write(f"**{key}:** {value}")