ahmadmac commited on
Commit
9bec5f7
·
verified ·
1 Parent(s): 62edeb9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import PyPDF2
3
+ import google.generativeai as genai
4
+
5
+ # Initialize Gemini Flash model with your API key
6
+ genai.configure(api_key=os.environ.get("Google_API_KEY"))
7
+ model = genai.GenerativeModel('gemini-1.5-flash')
8
+
9
+ # Function to extract text from uploaded PDF
10
+ def extract_text_from_pdf(pdf_file):
11
+ reader = PyPDF2.PdfReader(pdf_file)
12
+ text = ''
13
+ for page_num in range(len(reader.pages)):
14
+ page = reader.pages[page_num]
15
+ text += page.extract_text()
16
+ return text
17
+
18
+ # Function to process the CV and job description
19
+ def check_cv_match(cv_text, job_description):
20
+ prompt = (
21
+ f"You are an AI expert assisting with recruitment. "
22
+ f"Compare the following resume with the job description and determine if the resume matches the job requirements. "
23
+ f"Provide a detailed analysis and a match percentage:\n\n"
24
+ f"Job Description: {job_description}\n\n"
25
+ f"Resume: {cv_text}\n\n"
26
+ f"Give a score from 0% to 100% indicating how well the resume matches the job."
27
+ )
28
+
29
+ response = model.generate_content([prompt])
30
+ return response.text
31
+
32
+
33
+ st.title("CV and Job Description Matcher")
34
+
35
+ uploaded_cv = st.file_uploader("Upload CV (PDF format)", type="pdf")
36
+
37
+ if uploaded_cv is not None:
38
+ # Extract text from uploaded PDF
39
+ cv_text = extract_text_from_pdf(uploaded_cv)
40
+ st.text_area("Extracted CV Text", value=cv_text, height=300)
41
+
42
+ # Input field for job description
43
+ job_description = st.text_area("Enter the Job Description", height=300)
44
+
45
+ if st.button("Check Match"):
46
+ if uploaded_cv and job_description:
47
+ match_result = check_cv_match(cv_text, job_description)
48
+ st.write("Match Analysis:")
49
+ st.write(match_result)
50
+ else:
51
+ st.error("Please upload a CV and enter the job description.")