Last active
August 7, 2023 13:08
-
-
Save abhijeet-talaulikar/489ad7a68b52a9597c88b6d6e7d0e004 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Setup the page configuration ### | |
st.set_page_config(layout="wide", page_title="Concall Transcripts with GPT") | |
st.title('Concall Transcripts with GPT') | |
openai_api_key = st.sidebar.text_input('OpenAI API Key', value='') | |
if "response_default" not in st.session_state: | |
st.session_state['response_default'] = None | |
### Create UI elements ### | |
if "disabled" not in st.session_state: | |
st.session_state.disabled = False | |
def disable(): | |
st.session_state.disabled = True | |
with st.form('frm_file'): | |
url_file = st.text_input('URL to PDF file', '') | |
frm_file_submitted = st.form_submit_button('Search', on_click=disable, disabled=st.session_state.disabled) | |
if not openai_api_key.startswith('sk-'): | |
st.warning('Please enter your OpenAI API key!', icon='⚠') | |
op_default = st.container() | |
def updateDefaultBox(): | |
op_default.markdown(st.session_state['response_default']) | |
if st.session_state['response_default']: | |
updateDefaultBox() | |
### Create callback function ### | |
if frm_file_submitted and url_file!="": | |
if not openai_api_key.startswith('sk-'): | |
st.warning('Please enter your OpenAI API key!', icon='⚠') | |
else: | |
documents = read_pdf(url_file, False) | |
response_default = generate_default_response(documents) | |
st.session_state['documents'] = pickle.dumps(documents) | |
st.session_state['response_default'] = response_default | |
updateChatBox() | |
updateDefaultBox() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment