Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files- src/app.py +58 -57
src/app.py
CHANGED
|
@@ -1,58 +1,59 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
|
| 3 |
-
import
|
| 4 |
-
from utils import *
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
st.
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
st.
|
| 15 |
-
st.
|
| 16 |
-
st.
|
| 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 |
-
st.
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
| 58 |
main()
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
import uuid
|
| 4 |
+
from utils import *
|
| 5 |
+
|
| 6 |
+
if 'unique_id' not in st.session_state:
|
| 7 |
+
st.session_state['unique_id'] = ''
|
| 8 |
+
|
| 9 |
+
def main():
|
| 10 |
+
st.set_page_config(page_title="Resume Screening Assistance")
|
| 11 |
+
st.title("HR - Resume Screening Assistance...💁 ")
|
| 12 |
+
st.subheader("I can help you in resume screening process")
|
| 13 |
+
|
| 14 |
+
job_description = st.text_area("Please paste the 'JOB DESCRIPTION' here...", key="1")
|
| 15 |
+
document_count = st.text_input("No.of 'RESUMES' to return", key="2")
|
| 16 |
+
pdf = st.file_uploader("Upload resumes here, only PDF files allowed", type=["pdf"], accept_multiple_files=True)
|
| 17 |
+
|
| 18 |
+
submit = st.button("Help me with the analysis")
|
| 19 |
+
|
| 20 |
+
if submit:
|
| 21 |
+
API_TOKEN = os.getenv("HUGGINGFACEHUB_API_TOKEN")
|
| 22 |
+
if not API_TOKEN:
|
| 23 |
+
st.error("ERROR: HUGGINGFACEHUB_API_TOKEN not found. Set it in Hugging Face Space Secrets.")
|
| 24 |
+
return
|
| 25 |
+
|
| 26 |
+
try:
|
| 27 |
+
document_count = int(document_count)
|
| 28 |
+
except ValueError:
|
| 29 |
+
document_count = 5
|
| 30 |
+
|
| 31 |
+
from huggingface_hub import InferenceClient
|
| 32 |
+
hf_client = InferenceClient(token=API_TOKEN)
|
| 33 |
+
|
| 34 |
+
with st.spinner('Wait for it...'):
|
| 35 |
+
st.session_state['unique_id'] = uuid.uuid4().hex
|
| 36 |
+
final_docs_list = create_docs(pdf, st.session_state['unique_id'])
|
| 37 |
+
|
| 38 |
+
st.write("*Resumes uploaded* :" + str(len(final_docs_list)))
|
| 39 |
+
|
| 40 |
+
embeddings = create_embeddings_load_data()
|
| 41 |
+
|
| 42 |
+
push_to_chroma(st.session_state['unique_id'], embeddings, final_docs_list)
|
| 43 |
+
relavant_docs = similar_docs(job_description, document_count, st.session_state['unique_id'])
|
| 44 |
+
|
| 45 |
+
st.write(":heavy_minus_sign:" * 30)
|
| 46 |
+
|
| 47 |
+
for item in range(len(relavant_docs)):
|
| 48 |
+
st.subheader("👉 " + str(item + 1))
|
| 49 |
+
st.write("**File** : " + relavant_docs[item][0].metadata['name'])
|
| 50 |
+
|
| 51 |
+
with st.expander('Show me 👀'):
|
| 52 |
+
st.info("**Match Score** : " + str(relavant_docs[item][1]))
|
| 53 |
+
summary = get_summary(relavant_docs[item][0], hf_client)
|
| 54 |
+
st.write("**Summary** : " + summary)
|
| 55 |
+
|
| 56 |
+
st.success("Hope I was able to save your time❤️")
|
| 57 |
+
|
| 58 |
+
if __name__ == '__main__':
|
| 59 |
main()
|