adibak commited on
Commit
864d2d0
·
unverified ·
2 Parent(s): c85660d 804b415

Merge pull request #2 from AdiBak/feature/new-chat-button

Browse files
Files changed (1) hide show
  1. app.py +5 -28
app.py CHANGED
@@ -144,19 +144,12 @@ def reset_chat_history():
144
  st.session_state.pop(ADDITIONAL_INFO, None)
145
  st.session_state.pop(PDF_FILE_KEY, None)
146
 
147
- # Safely remove previously generated temp PPTX file
148
  temp_pptx_path = st.session_state.pop(DOWNLOAD_FILE_KEY, None)
149
  if temp_pptx_path:
150
- try:
151
- pptx_path = pathlib.Path(temp_pptx_path)
152
- if pptx_path.exists() and pptx_path.is_file():
153
- pptx_path.unlink()
154
- logger.info(f"Removed temporary PPTX file: {pptx_path}")
155
- except Exception as e:
156
- logger.warning(f"Failed to remove temporary PPTX file {temp_pptx_path}: {e}")
157
-
158
- st.rerun() # Reload the app
159
-
160
 
161
  APP_TEXT = _load_strings()
162
 
@@ -173,28 +166,14 @@ logger = logging.getLogger(__name__)
173
  texts = list(GlobalConfig.PPTX_TEMPLATE_FILES.keys())
174
  captions = [GlobalConfig.PPTX_TEMPLATE_FILES[x]['caption'] for x in texts]
175
 
176
- # CSS to reduce spacing around the new chat button
177
- st.markdown(
178
- """
179
- <style>
180
- div[data-testid="stHorizontalBlock"] {
181
- position: absolute;
182
- top: -25px !important;
183
- width: 100% !important;
184
- }
185
- </style>
186
- """,
187
- unsafe_allow_html=True)
188
 
189
  with st.sidebar:
190
  # New Chat button at the top of sidebar
191
- col1, col2, col3 = st.columns([1, 2, 1])
192
  with col2:
193
  if st.button('New Chat 💬', help='Start a new conversation', key='new_chat_button'):
194
  reset_chat_history() # Reset the chat history when the button is clicked
195
 
196
- st.markdown('---') # Separator
197
-
198
  # The PPT templates
199
  pptx_template = st.sidebar.radio(
200
  '1: Select a presentation template:',
@@ -338,8 +317,6 @@ def set_up_chat_ui():
338
  accept_file=True,
339
  file_type=['pdf', ],
340
  )
341
-
342
-
343
 
344
  if prompt:
345
  prompt_text = prompt.text or ''
 
144
  st.session_state.pop(ADDITIONAL_INFO, None)
145
  st.session_state.pop(PDF_FILE_KEY, None)
146
 
147
+ # Remove previously generated temp PPTX file
148
  temp_pptx_path = st.session_state.pop(DOWNLOAD_FILE_KEY, None)
149
  if temp_pptx_path:
150
+ pptx_path = pathlib.Path(temp_pptx_path)
151
+ if pptx_path.exists() and pptx_path.is_file():
152
+ pptx_path.unlink()
 
 
 
 
 
 
 
153
 
154
  APP_TEXT = _load_strings()
155
 
 
166
  texts = list(GlobalConfig.PPTX_TEMPLATE_FILES.keys())
167
  captions = [GlobalConfig.PPTX_TEMPLATE_FILES[x]['caption'] for x in texts]
168
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
  with st.sidebar:
171
  # New Chat button at the top of sidebar
172
+ col1, col2, col3 = st.columns([.17, 0.8, .1])
173
  with col2:
174
  if st.button('New Chat 💬', help='Start a new conversation', key='new_chat_button'):
175
  reset_chat_history() # Reset the chat history when the button is clicked
176
 
 
 
177
  # The PPT templates
178
  pptx_template = st.sidebar.radio(
179
  '1: Select a presentation template:',
 
317
  accept_file=True,
318
  file_type=['pdf', ],
319
  )
 
 
320
 
321
  if prompt:
322
  prompt_text = prompt.text or ''