import app_funtions as appfun
import os
import shutil
import glob
import gradio as gr
from pathlib import Path
from datetime import datetime
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("""
Resume Processing
""")
password_row = gr.Row()
password_text_row = gr.Row(visible=False)
content_row = gr.Row(visible=False)
confirmation_row = gr.Row(visible=False)
MIL_Password = gr.Textbox(type='password', label="Enter the Password", visible=True)
log_in = gr.Button("Log In", visible=True)
log_in.click(fn=appfun.check_password, inputs=MIL_Password,
outputs=[MIL_Password, log_in, password_text_row, content_row])
with password_text_row:
gr.Markdown("""Incorrect Password. Access Denied.
""")
with content_row:
with gr.Tab('Resume Input'):
gr.Markdown("""Resumes Input
""")
gr.Markdown("""Upload or delete any resumes you would like to have the AI use:""")
with gr.Row():
with gr.Column():
upload_resume = gr.UploadButton('Upload Resume', file_count="multiple")
with gr.Column():
delete_resume = gr.Button('Delete')
with gr.Row():
@gr.render(triggers=[upload_resume.upload, delete_resume.click, log_in.click])
def file_exp():
resume_file_explorer = gr.FileExplorer(
root_dir=os.path.abspath("Resumes"),
label='Resumes',
interactive=True,
elem_id='explorer',
)
upload_resume.upload(fn=appfun.add_resume, inputs=upload_resume)
delete_resume.click(fn=appfun.remove_resumes, inputs=resume_file_explorer)
with gr.Tab('Job Input'):
gr.Markdown("""Job Input
""")
gr.Markdown("""Upload a document you would like to extract job description from. Supported file types are: .pdf,
.docx, .pptx, .txt.""")
upload_file = gr.File()
extract_button = gr.Button('Extract')
extract_completion_message = gr.Markdown("""""")
with gr.Tab('Rank Resumes'):
gr.Markdown("""Rank Resumes
""")
gr.Markdown("""Choose the job posting of which you would like to get the top 3 resumes for.""")
job_select = gr.Dropdown(label='Select Job', choices=appfun.job_names + ['Custom'], allow_custom_value=True)
with gr.Row(visible=False) as job_details:
with gr.Column():
job_name_input = gr.Textbox(label='Job Name', lines=1, interactive=True)
job_description_input = gr.Textbox(label='Job Description', lines=5, interactive=True)
get_resumes = gr.Button('Rank Resumes')
with gr.Row(visible=True) as gpt_response:
best_resumes = gr.Markdown()
with gr.Tab("Chatbot"):
chatbot = gr.Chatbot(avatar_images=("user.jpeg", "gpt.jpg"), height=750)
state = gr.State()
chatbot_textbox = gr.Textbox(label="Input", info="", lines=1,
placeholder="Please process resumes", scale=1,
interactive=False)
chatbot_submit = gr.Button("SEND", interactive=False, scale=1)
chatbot_submit.click(appfun.my_chatbot, inputs=[chatbot_textbox, state],
outputs=[chatbot, state, chatbot_textbox])
job_select.select(fn=appfun.job_selected, inputs=job_select,
outputs=[job_name_input, job_description_input, job_details, best_resumes])
get_resumes.click(appfun.send_to_openai, inputs=[job_name_input, job_description_input],
outputs=[best_resumes, gpt_response, chatbot_textbox, chatbot_submit])
extract_button.click(fn=appfun.extract_jobs, inputs=upload_file, outputs=[extract_completion_message, job_select])
if __name__ == '__main__':
# Remove all current resumes from the Resumes folder
files = glob.glob(os.path.abspath('Resumes') + "/*")
for f in files:
os.remove(f)
demo.launch()