-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
110 lines (93 loc) · 3.99 KB
/
app.py
File metadata and controls
110 lines (93 loc) · 3.99 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
from dotenv import load_dotenv
import streamlit as st
import os
import io
import base64
from PIL import Image
import pdf2image
import google.generativeai as genai
# Load environment variables
load_dotenv()
# Configure Google Gemini API
API_KEY = os.getenv("GOOGLE_API_KEY")
if not API_KEY:
st.error("GOOGLE_API_KEY not found. Please set it in your environment variables.")
st.stop()
genai.configure(api_key=API_KEY)
def get_gemini_response(input_text, pdf_content, prompt):
"""Generate a response using Google Gemini API."""
model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content([input_text, pdf_content[0], prompt])
return response.text
def input_pdf_setup(uploaded_file):
"""Convert first page of uploaded PDF to an image and encode as base64."""
if uploaded_file is not None:
uploaded_file.seek(0) # Reset file pointer
images = pdf2image.convert_from_bytes(uploaded_file.read()) # Removed poppler_path
first_page = images[0]
# Convert image to bytes
img_byte_arr = io.BytesIO()
first_page.save(img_byte_arr, format='JPEG')
img_byte_arr = img_byte_arr.getvalue()
pdf_parts = [{
"mime_type": "image/jpeg",
"data": base64.b64encode(img_byte_arr).decode() # Encode to base64
}]
return pdf_parts
else:
raise FileNotFoundError("No File Uploaded")
# Streamlit App
st.set_page_config(page_title="A5 ATS Resume Expert")
st.header("MY A5 PERSONAL ATS")
input_text = st.text_area("Job Description:", key="input")
uploaded_file = st.file_uploader("Upload your resume (PDF)...", type=['pdf'])
if uploaded_file:
st.success("PDF Uploaded Successfully.")
submit1 = st.button("Tell Me About the Resume")
submit3 = st.button("Percentage Match")
submit4 = st.button("Personalized Learning Path")
input_prompt1 = """
You are an experienced HR with tech expertise in Data Science, Full Stack, Web Development, Big Data Engineering, DevOps, or Data Analysis.
Your task is to review the provided resume against the job description for these roles.
Please evaluate the candidate's profile, highlighting strengths and weaknesses in relation to the specified job role.
"""
input_prompt3 = """
You are a skilled ATS (Applicant Tracking System) scanner with expertise in Data Science, Full Stack, Web Development, Big Data Engineering, DevOps, and Data Analysis.
Your task is to evaluate the resume against the job description. Provide:
1. The percentage match.
2. Keywords missing.
3. Final evaluation.
"""
input_prompt4 = """
You are an experienced learning coach and technical expert. Create a 6-month personalized study plan for an individual aiming to excel in [Job Role],
focusing on the skills, topics, and tools specified in the provided job description. Ensure the study plan includes:
- A list of topics and tools for each month.
- Suggested resources (books, online courses, documentation).
- Recommended practical exercises or projects.
- Periodic assessments or milestones.
- Tips for real-world applications.
"""
if submit1:
if uploaded_file:
pdf_content = input_pdf_setup(uploaded_file)
response = get_gemini_response(input_prompt1, pdf_content, input_text)
st.subheader("The Response is:")
st.write(response)
else:
st.warning("Please upload a resume.")
elif submit3:
if uploaded_file:
pdf_content = input_pdf_setup(uploaded_file)
response = get_gemini_response(input_prompt3, pdf_content, input_text)
st.subheader("The Response is:")
st.write(response)
else:
st.warning("Please upload a resume.")
elif submit4:
if uploaded_file:
pdf_content = input_pdf_setup(uploaded_file)
response = get_gemini_response(input_prompt4, pdf_content, input_text)
st.subheader("The Response is:")
st.write(response)
else:
st.warning("Please upload a resume.")