Dhaerie commited on
Commit
a5a1bbf
·
verified ·
1 Parent(s): 4b547d0

Update src/app.py

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