Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,35 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
import google.generativeai as
|
3 |
import pandas as pd
|
4 |
from io import StringIO
|
|
|
5 |
|
6 |
-
#
|
7 |
-
|
|
|
8 |
|
9 |
-
def
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def extract_skills(resume_text):
|
15 |
-
|
16 |
-
|
17 |
-
skills = [entity['text'] for entity in response['entities']]
|
18 |
return skills
|
19 |
|
20 |
def match_job_description(resume_text, job_description):
|
21 |
-
|
22 |
-
|
23 |
-
score = response['similarity_score']
|
24 |
return score
|
25 |
|
26 |
# Streamlit application layout
|
@@ -30,18 +39,14 @@ st.header('Upload Resume')
|
|
30 |
uploaded_file = st.file_uploader('Choose a file', type=['pdf', 'docx', 'txt'])
|
31 |
|
32 |
if uploaded_file is not None:
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
36 |
|
37 |
st.subheader('Resume Text')
|
38 |
st.write(resume_text)
|
39 |
|
40 |
-
st.subheader('Analyze Resume')
|
41 |
-
if st.button('Analyze'):
|
42 |
-
analysis_result = analyze_resume(resume_text)
|
43 |
-
st.write('Analysis Result:', analysis_result)
|
44 |
-
|
45 |
st.subheader('Extract Skills')
|
46 |
if st.button('Extract Skills'):
|
47 |
skills = extract_skills(resume_text)
|
|
|
1 |
+
import os
|
2 |
import streamlit as st
|
3 |
+
import google.generativeai as genai
|
4 |
import pandas as pd
|
5 |
from io import StringIO
|
6 |
+
import fitz # PyMuPDF
|
7 |
|
8 |
+
# Configure Google Generative AI
|
9 |
+
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
10 |
+
model = genai.GenerativeModel('gemini-1.5-flash')
|
11 |
|
12 |
+
def extract_text_from_pdf(file):
|
13 |
+
"""Extract text from PDF."""
|
14 |
+
text = ""
|
15 |
+
doc = fitz.open(stream=file.read(), filetype="pdf")
|
16 |
+
for page in doc:
|
17 |
+
text += page.get_text()
|
18 |
+
return text
|
19 |
+
|
20 |
+
def get_gemini_response(prompt):
|
21 |
+
"""Function to load Google Gemini model and provide queries as response."""
|
22 |
+
response = model.generate_content([prompt])
|
23 |
+
return response[0]['text'] # Adjust this line based on actual response structure
|
24 |
|
25 |
def extract_skills(resume_text):
|
26 |
+
prompt = f"Extract the skills from the following resume:\n\n{resume_text}"
|
27 |
+
skills = get_gemini_response(prompt)
|
|
|
28 |
return skills
|
29 |
|
30 |
def match_job_description(resume_text, job_description):
|
31 |
+
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}"
|
32 |
+
score = get_gemini_response(prompt)
|
|
|
33 |
return score
|
34 |
|
35 |
# Streamlit application layout
|
|
|
39 |
uploaded_file = st.file_uploader('Choose a file', type=['pdf', 'docx', 'txt'])
|
40 |
|
41 |
if uploaded_file is not None:
|
42 |
+
if uploaded_file.type == "application/pdf":
|
43 |
+
resume_text = extract_text_from_pdf(uploaded_file)
|
44 |
+
else:
|
45 |
+
resume_text = uploaded_file.getvalue().decode("utf-8")
|
46 |
|
47 |
st.subheader('Resume Text')
|
48 |
st.write(resume_text)
|
49 |
|
|
|
|
|
|
|
|
|
|
|
50 |
st.subheader('Extract Skills')
|
51 |
if st.button('Extract Skills'):
|
52 |
skills = extract_skills(resume_text)
|