Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	Merge branch 'main' of https://github.com/AdiBak/slide-deck-ai
Browse files
    	
        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 | 
            -
                #  | 
| 148 | 
             
                temp_pptx_path = st.session_state.pop(DOWNLOAD_FILE_KEY, None)
         | 
| 149 | 
             
                if temp_pptx_path:
         | 
| 150 | 
            -
                     | 
| 151 | 
            -
             | 
| 152 | 
            -
                         | 
| 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 |  | 
| 162 | 
             
            APP_TEXT = _load_strings()
         | 
| @@ -174,28 +167,14 @@ logger = logging.getLogger(__name__) | |
| 174 | 
             
            texts = list(GlobalConfig.PPTX_TEMPLATE_FILES.keys())
         | 
| 175 | 
             
            captions = [GlobalConfig.PPTX_TEMPLATE_FILES[x]['caption'] for x in texts]
         | 
| 176 |  | 
| 177 | 
            -
            # CSS to reduce spacing around the new chat button
         | 
| 178 | 
            -
            st.markdown(
         | 
| 179 | 
            -
                """
         | 
| 180 | 
            -
                <style>
         | 
| 181 | 
            -
                div[data-testid="stHorizontalBlock"] {
         | 
| 182 | 
            -
                    position: absolute;
         | 
| 183 | 
            -
                    top: -25px !important;
         | 
| 184 | 
            -
                    width: 100% !important;
         | 
| 185 | 
            -
                }
         | 
| 186 | 
            -
                </style>
         | 
| 187 | 
            -
                """, 
         | 
| 188 | 
            -
                unsafe_allow_html=True)
         | 
| 189 |  | 
| 190 | 
             
            with st.sidebar:
         | 
| 191 | 
             
                # New Chat button at the top of sidebar
         | 
| 192 | 
            -
                col1, col2, col3 = st.columns([ | 
| 193 | 
             
                with col2:
         | 
| 194 | 
             
                    if st.button('New Chat 💬', help='Start a new conversation', key='new_chat_button'):
         | 
| 195 | 
             
                        reset_chat_history()  # Reset the chat history when the button is clicked
         | 
| 196 |  | 
| 197 | 
            -
                st.markdown('---')  # Separator
         | 
| 198 | 
            -
                
         | 
| 199 | 
             
                # The PPT templates
         | 
| 200 | 
             
                pptx_template = st.sidebar.radio(
         | 
| 201 | 
             
                    '1: Select a presentation template:',
         | 
| @@ -339,8 +318,6 @@ def set_up_chat_ui(): | |
| 339 | 
             
                    accept_file=True,
         | 
| 340 | 
             
                    file_type=['pdf', ],
         | 
| 341 | 
             
                )
         | 
| 342 | 
            -
                
         | 
| 343 | 
            -
             | 
| 344 |  | 
| 345 | 
             
                if prompt:
         | 
| 346 | 
             
                    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 |  | 
| 155 | 
             
            APP_TEXT = _load_strings()
         | 
|  | |
| 167 | 
             
            texts = list(GlobalConfig.PPTX_TEMPLATE_FILES.keys())
         | 
| 168 | 
             
            captions = [GlobalConfig.PPTX_TEMPLATE_FILES[x]['caption'] for x in texts]
         | 
| 169 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 170 |  | 
| 171 | 
             
            with st.sidebar:
         | 
| 172 | 
             
                # New Chat button at the top of sidebar
         | 
| 173 | 
            +
                col1, col2, col3 = st.columns([.17, 0.8, .1])
         | 
| 174 | 
             
                with col2:
         | 
| 175 | 
             
                    if st.button('New Chat 💬', help='Start a new conversation', key='new_chat_button'):
         | 
| 176 | 
             
                        reset_chat_history()  # Reset the chat history when the button is clicked
         | 
| 177 |  | 
|  | |
|  | |
| 178 | 
             
                # The PPT templates
         | 
| 179 | 
             
                pptx_template = st.sidebar.radio(
         | 
| 180 | 
             
                    '1: Select a presentation template:',
         | 
|  | |
| 318 | 
             
                    accept_file=True,
         | 
| 319 | 
             
                    file_type=['pdf', ],
         | 
| 320 | 
             
                )
         | 
|  | |
|  | |
| 321 |  | 
| 322 | 
             
                if prompt:
         | 
| 323 | 
             
                    prompt_text = prompt.text or ''
         |