Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -104,7 +104,9 @@ def build_ui():
|
|
104 |
|
105 |
st.title(APP_TEXT['app_name'])
|
106 |
st.subheader(APP_TEXT['caption'])
|
107 |
-
|
|
|
|
|
108 |
|
109 |
with st.expander('Usage Policies and Limitations'):
|
110 |
st.text(APP_TEXT['tos'] + '\n\n' + APP_TEXT['tos2'])
|
@@ -117,20 +119,21 @@ def set_up_chat_ui():
|
|
117 |
Prepare the chat interface and related functionality.
|
118 |
"""
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
)
|
127 |
-
st.info(
|
128 |
-
'As this is an academic project, we are limited in the time we can dedicate to development. '
|
129 |
-
'However, we are committed to enhancing **AI SlideMaker** over time, adding more features and improvements based on your suggestions. '
|
130 |
-
'Your support means a lot to us—please consider leaving a heart ❤️ and sharing your feedback. '
|
131 |
-
'Every bit of encouragement helps us make this tool as useful as possible for the public!'
|
132 |
)
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
# view_messages = st.expander('View the messages in the session state')
|
135 |
|
136 |
st.chat_message('ai').write(
|
@@ -237,8 +240,10 @@ def set_up_chat_ui():
|
|
237 |
history.add_ai_message(response)
|
238 |
|
239 |
# The content has been generated as JSON
|
240 |
-
# There maybe trailing
|
241 |
-
|
|
|
|
|
242 |
response_cleaned = text_helper.get_clean_json(response)
|
243 |
|
244 |
logger.info(
|
@@ -272,7 +277,7 @@ def generate_slide_deck(json_str: str) -> Union[pathlib.Path, None]:
|
|
272 |
deck, the path may be to an empty file.
|
273 |
|
274 |
:param json_str: The content in *valid* JSON format.
|
275 |
-
:return: The path to the .pptx file or
|
276 |
"""
|
277 |
|
278 |
try:
|
@@ -300,16 +305,16 @@ def generate_slide_deck(json_str: str) -> Union[pathlib.Path, None]:
|
|
300 |
except RecursionError:
|
301 |
st.error(
|
302 |
'Encountered an error while parsing JSON...'
|
303 |
-
'the slide
|
304 |
'\nPlease try again later.'
|
305 |
)
|
306 |
-
logger.error('Caught RecursionError while parsing JSON. Cannot generate the
|
307 |
|
308 |
return None
|
309 |
except Exception:
|
310 |
st.error(
|
311 |
'Encountered an error while parsing JSON...'
|
312 |
-
'the slide
|
313 |
'\nPlease try again later.'
|
314 |
)
|
315 |
logger.error(
|
@@ -418,4 +423,8 @@ def main():
|
|
418 |
|
419 |
|
420 |
if __name__ == '__main__':
|
421 |
-
main()
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
st.title(APP_TEXT['app_name'])
|
106 |
st.subheader(APP_TEXT['caption'])
|
107 |
+
st.markdown(
|
108 |
+
'' # noqa: E501
|
109 |
+
)
|
110 |
|
111 |
with st.expander('Usage Policies and Limitations'):
|
112 |
st.text(APP_TEXT['tos'] + '\n\n' + APP_TEXT['tos2'])
|
|
|
119 |
Prepare the chat interface and related functionality.
|
120 |
"""
|
121 |
|
122 |
+
with st.expander('Usage Instructions'):
|
123 |
+
st.markdown(GlobalConfig.CHAT_USAGE_INSTRUCTIONS)
|
124 |
+
st.markdown(
|
125 |
+
'[SlideDeck AI](https://github.com/barun-saha/slide-deck-ai) is an Open-Source project.' # noqa: E501
|
126 |
+
' It is is powered by' # noqa: E501
|
127 |
+
' [Mistral-Nemo-Instruct-2407](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407).' # noqa: E501
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
)
|
129 |
|
130 |
+
st.info(
|
131 |
+
'If you like SlideDeck AI, please consider leaving a heart ❤️ on the'
|
132 |
+
' [Hugging Face Space](https://huggingface.co/spaces/barunsaha/slide-deck-ai/) or'
|
133 |
+
' a star ⭐ on [GitHub](https://github.com/barun-saha/slide-deck-ai).'
|
134 |
+
' Your [feedback](https://forms.gle/JECFBGhjvSj7moBx9) is appreciated.'
|
135 |
+
)
|
136 |
+
|
137 |
# view_messages = st.expander('View the messages in the session state')
|
138 |
|
139 |
st.chat_message('ai').write(
|
|
|
240 |
history.add_ai_message(response)
|
241 |
|
242 |
# The content has been generated as JSON
|
243 |
+
# There maybe trailing
|
244 |
+
at the end of the response -- remove them
|
245 |
+
# To be careful:
|
246 |
+
may be part of the content as well when code is generated
|
247 |
response_cleaned = text_helper.get_clean_json(response)
|
248 |
|
249 |
logger.info(
|
|
|
277 |
deck, the path may be to an empty file.
|
278 |
|
279 |
:param json_str: The content in *valid* JSON format.
|
280 |
+
:return: The path to the .pptx file or None in case of error.
|
281 |
"""
|
282 |
|
283 |
try:
|
|
|
305 |
except RecursionError:
|
306 |
st.error(
|
307 |
'Encountered an error while parsing JSON...'
|
308 |
+
'the slide deck cannot be created, unfortunately ☹'
|
309 |
'\nPlease try again later.'
|
310 |
)
|
311 |
+
logger.error('Caught RecursionError while parsing JSON. Cannot generate the slide deck!')
|
312 |
|
313 |
return None
|
314 |
except Exception:
|
315 |
st.error(
|
316 |
'Encountered an error while parsing JSON...'
|
317 |
+
'the slide deck cannot be created, unfortunately ☹'
|
318 |
'\nPlease try again later.'
|
319 |
)
|
320 |
logger.error(
|
|
|
423 |
|
424 |
|
425 |
if __name__ == '__main__':
|
426 |
+
main()
|
427 |
+
|
428 |
+
|
429 |
+
|
430 |
+
|