Spaces:
Runtime error
Runtime error
File size: 5,405 Bytes
8dbf259 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
import streamlit as st
from dotenv import load_dotenv
from utils import *
import uuid
from langchain_community.vectorstores import FAISS
from langchain_chroma import Chroma
import pandas as pd
st.set_page_config(page_title="Resume Screening Assistance", layout="wide")
custom_html = """
<style>
h1 {
background-color: #e6763b;
padding: 20px;
margin: 0;
text-align: center; /* Center the text */
}
img {
max-width: 100%;
height: 31px;
margin-right: 20px;
margin-bottom: 6px;
}
h1 img {
vertical-align: middle;
}
</style>
<body>
<h1><img src="https://www.athmick.com/static/media/athmick-logo-with-name.32abc7ca97607204825eed0610ae2eea.svg">HR Resume Copilot ... ๐</h1>
</body>
"""
# Render the custom HTML
st.markdown(custom_html, unsafe_allow_html=True)
#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")
# st.title("HR - Resume Screening Assistance๐")
st.subheader("I can help you in resume screening process")
# Upload the Job Description (pdf files)
job_description = st.file_uploader("JOB DESCRIPTION", type=["pdf"])
# Upload the Resumes (pdf files)
pdf = st.file_uploader("RESUME", type=["pdf"],accept_multiple_files=True)
#document retrun count
document_count = st.text_input("No.of 'RESUMES' to return",key="2")
#submit button
submit = st.button("Help me with the analysis")
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()
#using faiss db
db = Chroma.from_documents(final_docs_list, embeddings)
job_description_txt = get_pdf_text(job_description)
#using faiss db for similarity search with similarity score
relavant_docs = db.similarity_search_with_relevance_scores(job_description_txt,k=int(document_count))
data = []
#For each item in relavant docs - we are displaying some info of it on the UI
for item in pdf:
# st.subheader("๐ "+str(item+1))
resume_txt = get_pdf_text(item)
# #Displaying Filepath
# document_object = final_docs_list[item][0]
# file_name = document_object.metadata.get('name', None)
finel_name = item.name
# st.write("**File** : "+str(finel_name))
#Introducing Expander feature
with st.expander('Show me ๐'):
# st.info("**Matched Vector Score** : "+str(relavant_docs[item][1]))
matched_result = opeani_response(resume_txt, job_description_txt)
matched_percentage, reason, skills_to_improve, keywords, irrelevant = get_strip_response(matched_result)
#Gets the summary of the current item using 'get_summary' function that we have created which uses LLM & Langchain chain
summary = get_summary(resume_txt)
# Append the information to the DataFrame
data.append([finel_name, matched_percentage, reason, skills_to_improve, keywords, irrelevant, summary])
table_data = pd.DataFrame(data, columns=["File", "Matched Score", "Matched Reason" , "Skills to improve", "Keywords", "Irrelevant", "Summary"])
# Sort the DataFrame based on the 'Matched Score' column in descending order
df_sorted = table_data.sort_values(by='Matched Score', ascending=False)
# Reset the index
df_sorted.reset_index(drop=True, inplace=True)
# Loop through each row and print in the specified format
for index, row in df_sorted.iterrows():
st.write("**File** : "+row["File"])
st.info("**Matched Score ๐ฏ** : " + str(row["Matched Score"]) + "%")
st.write("**Matched Reason ๐** : " + row["Matched Reason"])
st.write("**Skills to improve ๐ฏ** : " + row["Skills to improve"])
st.write("**Keywords ๐๏ธ** : " + row["Keywords"])
st.write("**Irrelevant ๐** : " + row["Irrelevant"])
st.write("**Summary ๐** : " + row["Summary"])
st.write("## Relevant Documents")
st.table(df_sorted)
# graph = ploty_graph(matched_percentage_dict)
# st.plotly_chart(graph)
csv = df_sorted.to_csv().encode('utf-8')
st.download_button(
label="Download data as CSV",
data=csv,
file_name='Result Data.csv',
mime='text/csv',
)
st.success("Hope I was able to save your timeโค๏ธ")
#Invoking main function
if __name__ == '__main__':
main() |