CV_Reviewer / app.py
Jonah Ramponi
hf padding issue
f7a8e9f
"""
For HF, the interface should be called app.py
"""
import pathlib
import streamlit as st
from utils.process_doc import parse_docx, parse_pdf
from Interview import InterviewPage
from CVReview import CVReviewPage
CURRENT_DIR = pathlib.Path(__file__).parent.resolve()
def main():
st.set_page_config(layout="wide")
if "api_key" not in st.session_state:
st.session_state.api_key = ""
if "report" not in st.session_state:
st.session_state.report = {}
if "shared_materials" not in st.session_state:
st.session_state.shared_materials = {"valid_flag": False, "report": None}
SHARED_MATERIALS = st.session_state.shared_materials
st.markdown("\n")
st.markdown("\n")
st.markdown("\n")
with st.sidebar:
st.session_state["api_key"] = st.text_input(
"Cohere API Key Entry",
value="",
placeholder="Enter your Free Tier Cohere API Key",
)
job_posting_upload_box = st.text_area(
"Job Description Upload Box",
value="",
placeholder="Copy and Paste the contents of a job post you are interested in.",
help="In this box, please dump text content for a job description you are interested in. This could easily be setup to work directly with a webpage (we'd simply need to scrape said page) however I do not want to do that on HF spaces.",
)
cv_upload_box = st.file_uploader(
"CV Upload Box",
help="Upload your CV in .docx or .pdf form. This CV will be parsed, and used to analyse against the given job post.",
type=["docx", "pdf"],
accept_multiple_files=False,
)
if cv_upload_box and job_posting_upload_box != "":
SHARED_MATERIALS["job_posting"] = job_posting_upload_box
cv_filetype = cv_upload_box.name.split(".")[-1]
cv_file_contents = cv_upload_box.getvalue()
SHARED_MATERIALS["cv"] = (
parse_docx(cv_file_contents)
if cv_filetype == "docx"
else parse_pdf(cv_file_contents)
)
SHARED_MATERIALS["valid_flag"] = True
pg = st.navigation(
{
"Jonah's AI Job Tools": [
st.Page(
InterviewPage,
title="Practice Interview",
icon=":material/chat:",
),
st.Page(
CVReviewPage,
title="CV Review",
icon=":material/description:",
),
],
}
)
pg.run()
if __name__ == "__main__":
main()