Spaces:
Build error
Build error
Add exception handling for JSON parsing and slide deck generation
Browse filesFiles changed (2)
- chat_app.py+15-9
- strings.json+4-3
138 unmodified lines1391401411421431441451461471481491506 unmodified lines157158159160161162163164165166167168169170171138 unmodified linesprogress_bar_pptx.progress(100, text='Done!')def generate_slide_deck(json_str: str) -> List:"""Create a slide deck.:param json_str: The content in *valid* JSON format.:return: A list of all slide headers and the title."""if DOWNLOAD_FILE_KEY in st.session_state:6 unmodified lineslogger.debug('DOWNLOAD_FILE_KEY not found in session')logger.debug('Creating PPTX file: %s...', st.session_state[DOWNLOAD_FILE_KEY])all_headers = pptx_helper.generate_powerpoint_presentation(json_str,slides_template=pptx_template,output_file_path=path)_display_download_button(path)return all_headersdef _clean_json(json_str: str) -> str:138 unmodified lines1391401411421431441451461471481496 unmodified lines156157158159160161162163164165166167168169170171172173174175176177138 unmodified linesprogress_bar_pptx.progress(100, text='Done!')def generate_slide_deck(json_str: str):"""Create a slide deck.:param json_str: The content in *valid* JSON format."""if DOWNLOAD_FILE_KEY in st.session_state:6 unmodified lineslogger.debug('DOWNLOAD_FILE_KEY not found in session')logger.debug('Creating PPTX file: %s...', st.session_state[DOWNLOAD_FILE_KEY])try:pptx_helper.generate_powerpoint_presentation(json_str,slides_template=pptx_template,output_file_path=path)_display_download_button(path)except ValueError as ve:st.error(APP_TEXT['json_parsing_error'])logger.error('%s', APP_TEXT['json_parsing_error'])logger.error('Additional error info: %s', str(ve))except Exception as ex:st.error(APP_TEXT['content_generation_error'])logger.error('Caught a generic exception: %s', str(ex))def _clean_json(json_str: str) -> str:
12345616 unmodified lines23242526272829303132333435{"app_name": ":green[SlideDeck AI $^{[Reloaded]}$]","caption": "Converse, create, iterate, and improve your next PowerPoint slide deck","section_headers": ["Step 1: Generate your content","Step 2: Make it structured",16 unmodified lines],"urls_info": "Here is a list of some online resources that you can consult for further information on this topic:","image_info": "Got some more minutes? We are also trying to deliver an AI-generated art on the presentation topic, fresh off the studio, just for you!","content_generation_failure_error": "Unfortunately, SlideDeck AI failed to generate any content for you! Please try again later.","tos": "SlideDeck AI is an experimental prototype, and it has its limitations.\nPlease carefully review any and all AI-generated content.","tos2": "By using SlideDeck AI, you agree to fair and responsible usage.\nNo liability assumed by any party.","ai_greetings": ["How may I help you today?","Stuck with creating your presentation? Let me help you.","Looks like you have a looming deadline. Can I help you start with your slide deck?","Hello! What topic do you have on your mind today?"],"chat_placeholder": "Write the topic or instructions here"12345616 unmodified lines2324252627282930313233343536{"app_name": ":green[SlideDeck AI $^{[Reloaded]}$]","caption": "*Converse, create, iterate, and improve your next PowerPoint slide deck*","section_headers": ["Step 1: Generate your content","Step 2: Make it structured",16 unmodified lines],"urls_info": "Here is a list of some online resources that you can consult for further information on this topic:","image_info": "Got some more minutes? We are also trying to deliver an AI-generated art on the presentation topic, fresh off the studio, just for you!","content_generation_error": "Unfortunately, SlideDeck AI failed to generate any content for you! Please try again later.","json_parsing_error": "Unfortunately, SlideDeck AI failed to parse the response from LLM! Please try again by rephrasing the query or refreshing the page.","tos": "SlideDeck AI is an experimental prototype, and it has its limitations.\nPlease carefully review any and all AI-generated content.","tos2": "By using SlideDeck AI, you agree to fair and responsible usage.\nNo liability assumed by any party.","ai_greetings": ["How may I help you today?","Stuck with creating your presentation? Let me help you.","Looks like you have a looming deadline. Can I help you get started with your slide deck?","Hello! What topic do you have on your mind today?"],"chat_placeholder": "Write the topic or instructions here"
chat_app.py+15-9
strings.json+4-3