WorkGenius / app.py
mbosse99's picture
Adding second file upload for resume
18b432b
raw
history blame
3.93 kB
import streamlit as st
from streamlit_js_eval import streamlit_js_eval
from azure.storage.blob import BlobServiceClient
import json
import os
import uuid
connection_string = os.getenv("CONNECTION")
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
def upload_blob(pdf_name, json_data, pdf_data_jobdescription,pdf_data_cv):
try:
container_name = "jobdescriptions"
json_blob_name = f"{pdf_name}_jsondata.json"
pdf_blob_name_jobdescription = f"{pdf_name}.pdf"
pdf_blob_name_cv = f"{pdf_name}_resume.pdf"
container_client = blob_service_client.get_container_client(container_name)
json_blob_client = container_client.get_blob_client(json_blob_name)
json_blob_client.upload_blob(json_data.encode('utf-8'), overwrite=True)
pdf_blob_client = container_client.get_blob_client(pdf_blob_name_jobdescription)
pdf_blob_client.upload_blob(pdf_data_jobdescription, overwrite=True)
pdf_blob_client = container_client.get_blob_client(pdf_blob_name_cv)
pdf_blob_client.upload_blob(pdf_data_cv, overwrite=True)
link = "https://tensora.ai/workgenius/cv-evaluation2/?job="+pdf_name
st.success('Data and PDF files have been successfully uploaded. The link to the chatbot for the potential candidate is the following: ')
st.write(link)
return True
except Exception as e:
print(f"Fehler beim Hochladen der Daten: {str(e)}")
return False
def test(text_val):
print(text_val)
def main():
st.markdown(
"""
<style>
[data-testid=column]{
text-align: center;
display: flex;
align-items: center;
justify-content: center;
}
</style>
""",
unsafe_allow_html=True,
)
col1, col2 = st.columns([2, 1])
col1.title("Job description upload")
col2.image("https://www.workgenius.com/wp-content/uploads/2023/03/WorkGenius_navy-1.svg")
st.write("Please upload the job description and resume as PDF and enter the job title for the position. To receive the evaluation of the potential candidate, please provide your email address.")
upload_success = True
with st.form("job_inputs",clear_on_submit=True):
uploaded_file_jobdescription = st.file_uploader("Upload the job description:", type=["pdf"])
uploaded_file_cv = st.file_uploader("Upload the resume:", type=["pdf"])
job_title = st.text_input("Enter the job title:")
email = st.text_input("Enter the email:")
submitted = st.form_submit_button("Submit")
if submitted:
if len(job_title) > 0 and len(email) > 0 and uploaded_file_jobdescription and uploaded_file_cv:
data = {
"title": job_title,
"email": email
}
json_data = json.dumps(data, ensure_ascii=False)
# Eine zufällige UUID generieren
random_uuid = uuid.uuid4()
# Die UUID als String darstellen
uuid_string = str(random_uuid)
pdf_name = uuid_string
pdf_data_jobdescription = uploaded_file_jobdescription.read()
pdf_data_cv = uploaded_file_cv.read()
upload_success = upload_blob(pdf_name, json_data, pdf_data_jobdescription,pdf_data_cv)
else:
st.write("Please fill out both fields and upload a PDF file.")
if not upload_success:
st.error('An error has occurred. Please contact the administrator. Sorry for the inconvenience.', icon="🚨")
else:
col_empty, col_btn = st.columns([5, 1])
if col_btn.button("Clear" ,key="clear_btn",use_container_width=True):
streamlit_js_eval(js_expressions="parent.window.location.reload()")
if __name__ == "__main__":
main()