-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
46 lines (35 loc) · 1.27 KB
/
app.py
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
import streamlit as st
import os
from processor import Processor
# Page title
st.set_page_config(page_title='Cover Letter Generator')
st.title('Cover Letter Generator')
# Resume
resume_file = st.file_uploader('Upload a resume', type='pdf')
# File upload
job_description_file = st.file_uploader('Upload a job description', type='txt')
word_count = st.selectbox(
'How many words for the cover letter?',
('100', '200', '300')
)
tone = st.selectbox(
'Select a tone',
('casual', 'convincing', 'enthusiastic', 'formal', 'humorous', 'thoughtful')
)
# Form input and query
result = []
with st.form('myform', clear_on_submit=True):
if "openai_api_key" in st.secrets:
openai_api_key = st.secrets['openai_api_key']
else:
openai_api_key = st.text_input('OpenAI API Key', type='password')
submitted = st.form_submit_button('Submit', disabled=not(resume_file and job_description_file))
if submitted:
with st.spinner('Calculating...'):
os.environ["OPENAI_API_KEY"] = openai_api_key
the_processor = Processor(word_count, tone)
response = the_processor.process(resume_file, job_description_file)
st.info(response)
result.append(response)
#if len(result):
# st.info(response)