cm0805 commited on
Commit
da138ab
β€’
1 Parent(s): 8fcaa6a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +115 -0
app.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import packages
2
+ import streamlit as st
3
+ import os
4
+ from utils import load_file, plot_similarity_scores
5
+ from constants import StreamlitException
6
+
7
+ from nlp import (
8
+ clean_text, split_text, summarize_text,
9
+ extract_person_names_and_email, extract_tech_skills,
10
+ calculate_similarity, qna_query, lang_model
11
+ )
12
+
13
+ from constants import API_TOKEN, VESRION
14
+ os.environ["HUGGINGFACEHUB_API_TOKEN"] = API_TOKEN
15
+
16
+ def process_exception(e):
17
+ st.error(e.message)
18
+ st.stop()
19
+
20
+
21
+ if __name__ == "__main__":
22
+ # Set page width to a larger size
23
+ st.set_page_config(layout="wide")
24
+
25
+ # Streamlit app UI
26
+ st.write(
27
+ """<h1 style='display: inline-block; color: black;'>ResuMate.IO</h1>
28
+ <h3 style='display: inline-block; color: grey'>πŸš€ Transforming the recruitment and staffing experience through Generative AI </h3>""",
29
+ unsafe_allow_html=True
30
+ )
31
+ st.write("")
32
+ st.write("")
33
+
34
+ st.sidebar.write("")
35
+ with st.sidebar.expander("πŸ€– About", expanded=False):
36
+ st.write("This app is powered by free and open-source **Langchain** and **LLM technology**.")
37
+ st.write("Developed by **[Chandramauli Chaudhuri](https://www.linkedin.com/in/chandramaulic/)**.")
38
+ st.write("")
39
+ st.write(f"Version **{VESRION}**.")
40
+
41
+ # Upload a file, share job description and summarize its content
42
+ #st.sidebar.write("")
43
+ st.sidebar.header("User Inputs")
44
+ #st.sidebar.write("")
45
+ job_description_raw = st.sidebar.text_area("Enter the job description:")
46
+ #st.sidebar.write("")
47
+ job_description = clean_text(job_description_raw)
48
+ #st.write("")
49
+
50
+ uploaded_file = st.sidebar.file_uploader("Upload a resume:", type=["docx", "pdf", "ppt", "pptx"])
51
+ #st.sidebar.write("")
52
+
53
+ # Spinner set-up
54
+ with st.spinner("Details loading, please wait.."):
55
+ if uploaded_file is not None:
56
+ load_file_result = load_file(st, uploaded_file)
57
+ if type(load_file_result) is StreamlitException:
58
+ process_exception(load_file_result)
59
+ else:
60
+ resume_text_raw, lang_loader = load_file_result
61
+
62
+ resume_text = clean_text(resume_text_raw)
63
+ doc = lang_model(resume_text)
64
+
65
+ st.subheader("πŸ“ƒ Overview")
66
+ st.write("")
67
+
68
+ # Set up candidate name & email extraction
69
+ person_names, emails = extract_person_names_and_email(resume_text)
70
+ st.write("**Candidate's name:** " + ", ".join(person_names))
71
+ st.write("")
72
+ st.write("**Candidate's email address:** " + ", ".join(emails))
73
+ st.write("")
74
+
75
+ # Set up job description summarization
76
+ summarization_result = summarize_text(job_description)
77
+ if type(summarization_result) is StreamlitException:
78
+ process_exception(summarization_result)
79
+ else:
80
+ st.write("**Job description summary:** " + summarization_result)
81
+ st.write("")
82
+
83
+ # Set up resume summarization
84
+ summarization_result = summarize_text(resume_text)
85
+ if type(summarization_result) is StreamlitException:
86
+ process_exception(summarization_result)
87
+ else:
88
+ st.write("**Candidate's resume summary:** " + summarization_result)
89
+ st.write("")
90
+
91
+ st.write("")
92
+ st.subheader("πŸ” Fitment")
93
+ st.write("")
94
+
95
+ # Set up technical skill extraction
96
+ st.write("**Candidate's key technical skills:** " + ", ".join(extract_tech_skills(doc)))
97
+ st.write("")
98
+
99
+ # Set up percentage match calculation
100
+ st.write("**Percentage match between job description and candidate's resume:** " + f"{calculate_similarity(job_description, resume_text):.2f}%" + "\n")
101
+ st.write("")
102
+
103
+ # Set up percentage match calculation at sentence level
104
+ job_description_phrases = split_text(job_description)
105
+ resume_phrases = split_text(resume_text)
106
+ st.write('**Percentage resume match against TOP 10 job description items:**')
107
+ if job_description_raw != '':
108
+ fig = plot_similarity_scores(job_description_phrases, resume_phrases)
109
+ st.plotly_chart(fig, use_container_width=True)
110
+
111
+ # Set up user Q&A
112
+ user_input = st.sidebar.text_input("Ask any other resume-related questions:", "")
113
+ if user_input:
114
+ answer = qna_query(lang_loader, user_input)
115
+ st.sidebar.write(answer)