Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
from utils import *
|
4 |
+
import uuid
|
5 |
+
|
6 |
+
#Creating session variables
|
7 |
+
if 'unique_id' not in st.session_state:
|
8 |
+
st.session_state['unique_id'] =''
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
# if 'index' not in st.session_state:
|
15 |
+
# st.session_state['index'] = 0
|
16 |
+
|
17 |
+
# def next_index():
|
18 |
+
|
19 |
+
# st.session_state['index'] += 1
|
20 |
+
|
21 |
+
# def prev_index():
|
22 |
+
# if st.session_state['index'] > 1 :
|
23 |
+
# st.session_state['index'] -= 1
|
24 |
+
# else:
|
25 |
+
# pass
|
26 |
+
|
27 |
+
def main():
|
28 |
+
load_dotenv()
|
29 |
+
|
30 |
+
custom_css = """
|
31 |
+
<style>
|
32 |
+
body {
|
33 |
+
background-color: #29293d; /* Set your desired background color here */
|
34 |
+
}
|
35 |
+
</style>
|
36 |
+
"""
|
37 |
+
|
38 |
+
st.set_page_config(page_title="Resume Matcher - Dashboard")
|
39 |
+
st.title("Resume Matcher")
|
40 |
+
st.markdown(custom_css, unsafe_allow_html=True)
|
41 |
+
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
job_description = st.text_area("Specify the job description to match against :",key="1")
|
46 |
+
document_count = st.text_input("Number of resumes to return: ",key="2")
|
47 |
+
|
48 |
+
# option2 = st.selectbox("Choose an option:", ["Upload", "Continue Without Uploading"])
|
49 |
+
option = st.radio("Do you want to upload new resumes with this request ? :", ["Yes", "No" ])
|
50 |
+
|
51 |
+
# Display content based on the selected option
|
52 |
+
if option == "Yes":
|
53 |
+
st.header("Upload Section")
|
54 |
+
resume = st.file_uploader("Upload resumes here, (docx pdf md files allowed) ", type=["pdf", "docx", "md"],accept_multiple_files=True)
|
55 |
+
if resume :
|
56 |
+
st.success("File uploaded successfully!")
|
57 |
+
# Process the uploaded file if needed
|
58 |
+
|
59 |
+
# st.subheader("I can help you in resume screening process")
|
60 |
+
|
61 |
+
|
62 |
+
submit=st.button("Get Resumes")
|
63 |
+
|
64 |
+
if submit:
|
65 |
+
with st.spinner('Wait for it...'):
|
66 |
+
|
67 |
+
#Creating a unique ID, so that we can use to query and get only the user uploaded documents from PINECONE vector store
|
68 |
+
st.session_state['unique_id']= "aaa365fe031e4b5ab90aba54eaf6012e"
|
69 |
+
|
70 |
+
#Create a documents list out of all the user uploaded pdf files
|
71 |
+
|
72 |
+
#Displaying the count of resumes that have been uploaded
|
73 |
+
# st.write("*Resumes uploaded* :"+str(len(final_docs_list)))
|
74 |
+
|
75 |
+
#Create embeddings instance
|
76 |
+
embeddings=create_embeddings_load_data()
|
77 |
+
|
78 |
+
if option == "Yes":
|
79 |
+
#Push data to PINECONE
|
80 |
+
final_docs_list=create_docs(resume ,st.session_state['unique_id'])
|
81 |
+
push_to_pinecone("ad12a7c3-b36f-4b48-986e-5157cca233ef","gcp-starter","resume-db",embeddings,final_docs_list)
|
82 |
+
|
83 |
+
#Fecth relavant documents from PINECONE
|
84 |
+
relevant_docs = similar_docs(job_description,document_count,"ad12a7c3-b36f-4b48-986e-5157cca233ef","gcp-starter","resume-db",embeddings,st.session_state['unique_id'])
|
85 |
+
|
86 |
+
# score, relavant_docs = similar_docs_hf(query= job_description , final_docs_list=final_docs_list, k = document_count )
|
87 |
+
#t.write(relavant_docs)
|
88 |
+
|
89 |
+
#Introducing a line separator
|
90 |
+
st.write(":heavy_minus_sign:" * 30)
|
91 |
+
|
92 |
+
|
93 |
+
|
94 |
+
#For each item in relavant docs - we are displaying some info of it on the UI
|
95 |
+
|
96 |
+
# for item in range(len(relevant_docs)):
|
97 |
+
|
98 |
+
|
99 |
+
# st.button('Next ', on_click=next_index )
|
100 |
+
|
101 |
+
# st.button('Previous' , on_click= prev_index )
|
102 |
+
|
103 |
+
# st.write(st.session_state['index'])
|
104 |
+
|
105 |
+
#Displaying Filepath
|
106 |
+
|
107 |
+
# for item in range(len(relavant_docs)):
|
108 |
+
|
109 |
+
st.subheader("🔍 "+str("Following are best matching resumes of job description"))
|
110 |
+
|
111 |
+
#Displaying File Name
|
112 |
+
names = metadata_filename(relevant_docs )
|
113 |
+
scores = get_score(relevant_docs)
|
114 |
+
content = docs_content(relevant_docs)
|
115 |
+
|
116 |
+
for i, name in enumerate(names):
|
117 |
+
|
118 |
+
st.subheader("👉 "+str(i+1))
|
119 |
+
st.write("**File** : "+str(name[0]) )
|
120 |
+
with st.expander('Show me 👀'):
|
121 |
+
|
122 |
+
st.info("**Match Score** : "+str(scores[i]))
|
123 |
+
|
124 |
+
# st.write("***", content[i] )
|
125 |
+
|
126 |
+
st.write("**Summary**", get_summary(relevant_docs[i][0]))
|
127 |
+
|
128 |
+
# st.write("**File** : "+relavant_docs[item][0].metadata['name'])
|
129 |
+
|
130 |
+
|
131 |
+
#Introducing Expander feature
|
132 |
+
|
133 |
+
# with st.expander('Show me 👀'):
|
134 |
+
# scores = get_score(relevant_docs)
|
135 |
+
# st.info("**Match Score** : "+str(scores))
|
136 |
+
# content = docs_content(relevant_docs)
|
137 |
+
# st.write("***",content)
|
138 |
+
|
139 |
+
#Gets the summary of the current item using 'get_summary' function that we have created which uses LLM & Langchain chain
|
140 |
+
|
141 |
+
# st.write("**Summary** : ",summary)
|
142 |
+
|
143 |
+
# st.success("Hope I was able to save your time❤️")
|
144 |
+
|
145 |
+
|
146 |
+
# #Invoking main function
|
147 |
+
if __name__ == '__main__':
|
148 |
+
main()
|
149 |
+
|
150 |
+
|