hr_screening / app.py
MarsiyaIssah's picture
Rename streamlit.py to app.py
17371ce verified
import streamlit as st
from dotenv import load_dotenv
from utils import *
import uuid
#Creating session variables
if 'unique_id' not in st.session_state:
st.session_state['unique_id'] =''
def main():
load_dotenv()
st.set_page_config(page_title="Resume Screening Assistance", page_icon="📝")
st.title("HR - Resume Screening Assistance...")
# st.subheader("I can help you in resume screening process")
job_description = st.text_area("Please paste the 'JOB DESCRIPTION' here...", key="desc")
document_count = st.text_input("Enter the no.of resumes to return",key="count")
# Upload the Resumes (pdf files)
pdf = st.file_uploader("Upload resumes here, only PDF files allowed", type=["pdf"], accept_multiple_files=True)
submit=st.button("Screen")
if submit:
with st.spinner('Wait for it...'):
#Creating a unique ID, so that we can use to query and get only the user uploaded documents from PINECONE vector store
st.session_state['unique_id']=uuid.uuid4().hex
#Create a documents list out of all the user uploaded pdf files
final_docs_list=create_docs(pdf,st.session_state['unique_id'])
#Displaying the count of resumes that have been uploaded
st.write("*Resumes uploaded* :"+str(len(final_docs_list)))
#Create embeddings instance
embeddings=create_embeddings_load_data()
#Push data to PINECONE
# using already created index automatic-ticket-tool
table = push_to_lancedb(embeddings)
#Fecth relavant documents from LanceDB
relavant_docs = similar_docs_lancedb(job_description,table,embeddings,final_docs_list)
#st.write(relavant_docs)
#Introducing a line separator
st.write(":heavy_minus_sign:" * 30)
st.success(f"Find below the {document_count} Resumes")
# For each item in relavant docs - we are displaying some info of it on the UI
for idx, resume in enumerate(relavant_docs[:int(document_count)]):
st.subheader("👉 Resume "+str(idx+1))
# st.write(resume.page_content)
#Gets the summary of the current item using 'get_summary' function that we have created which uses LLM & Langchain chain
summary = get_summary(relavant_docs[idx])
print([relavant_docs[idx]])
st.write("**Summary** : "+summary)
st.success("Hope I was able to save your time❤️")
#Invoking main function
if __name__ == '__main__':
main()