Spaces:
Sleeping
Sleeping
File size: 2,644 Bytes
22be37d 0c94c61 22be37d 0c94c61 f7a8e9f 0c94c61 0c3cc21 0c94c61 22be37d 0c94c61 98eaa40 22be37d 0c94c61 |
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 |
"""
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()
|