Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,9 +104,7 @@ def build_ui():
|
|
| 104 |
|
| 105 |
st.title(APP_TEXT['app_name'])
|
| 106 |
st.subheader(APP_TEXT['caption'])
|
| 107 |
-
|
| 108 |
-
'' # noqa: E501
|
| 109 |
-
)
|
| 110 |
|
| 111 |
with st.expander('Usage Policies and Limitations'):
|
| 112 |
st.text(APP_TEXT['tos'] + '\n\n' + APP_TEXT['tos2'])
|
|
@@ -118,28 +116,33 @@ def set_up_chat_ui():
|
|
| 118 |
"""
|
| 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 |
-
'
|
| 126 |
-
'
|
| 127 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
)
|
| 129 |
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
| 138 |
|
| 139 |
st.chat_message('ai').write(
|
| 140 |
random.choice(APP_TEXT['ai_greetings'])
|
| 141 |
)
|
| 142 |
-
|
| 143 |
history = StreamlitChatMessageHistory(key=CHAT_MESSAGES)
|
| 144 |
|
| 145 |
if _is_it_refinement():
|
|
@@ -240,10 +243,8 @@ def set_up_chat_ui():
|
|
| 240 |
history.add_ai_message(response)
|
| 241 |
|
| 242 |
# The content has been generated as JSON
|
| 243 |
-
# There maybe trailing
|
| 244 |
-
|
| 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,7 +278,7 @@ def generate_slide_deck(json_str: str) -> Union[pathlib.Path, None]:
|
|
| 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,16 +306,16 @@ def generate_slide_deck(json_str: str) -> Union[pathlib.Path, None]:
|
|
| 305 |
except RecursionError:
|
| 306 |
st.error(
|
| 307 |
'Encountered an error while parsing JSON...'
|
| 308 |
-
'the slide
|
| 309 |
'\nPlease try again later.'
|
| 310 |
)
|
| 311 |
-
logger.error('Caught RecursionError while parsing JSON. Cannot generate the
|
| 312 |
|
| 313 |
return None
|
| 314 |
except Exception:
|
| 315 |
st.error(
|
| 316 |
'Encountered an error while parsing JSON...'
|
| 317 |
-
'the slide
|
| 318 |
'\nPlease try again later.'
|
| 319 |
)
|
| 320 |
logger.error(
|
|
@@ -424,7 +425,4 @@ def main():
|
|
| 424 |
|
| 425 |
if __name__ == '__main__':
|
| 426 |
main()
|
| 427 |
-
|
| 428 |
-
|
| 429 |
-
|
| 430 |
-
|
|
|
|
| 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'])
|
|
|
|
| 116 |
"""
|
| 117 |
Prepare the chat interface and related functionality.
|
| 118 |
"""
|
|
|
|
| 119 |
with st.expander('Usage Instructions'):
|
| 120 |
st.markdown(GlobalConfig.CHAT_USAGE_INSTRUCTIONS)
|
| 121 |
st.markdown(
|
| 122 |
+
'**AI SlideMaker** is our FYP project (Module 1) under the supervision of Maam Fouzia. '
|
| 123 |
+
'It is powered by [Mistral-Nemo-Instruct-2407](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407). '
|
| 124 |
+
'Group members: Usman Yousaf, Faisal Nawaz Khan, Mahnoor Asghar.'
|
| 125 |
+
)
|
| 126 |
+
st.info(
|
| 127 |
+
'As this is an academic project, we are limited in the time we can dedicate to development. '
|
| 128 |
+
'However, we are committed to enhancing **AI SlideMaker** over time, adding more features and improvements based on your suggestions. '
|
| 129 |
+
'Your support means a lot to us—please consider leaving a heart ❤️ and sharing your feedback. '
|
| 130 |
+
'Every bit of encouragement helps us make this tool as useful as possible for the public!'
|
| 131 |
)
|
| 132 |
|
| 133 |
+
# Feedback Section
|
| 134 |
+
with st.expander('Leave Your Feedback'):
|
| 135 |
+
feedback = st.text_area("We would love to hear your thoughts! Please share your feedback or suggestions below:")
|
| 136 |
+
if st.button("Submit Feedback"):
|
| 137 |
+
# Here, you can implement the logic to handle feedback submission
|
| 138 |
+
st.success("Thank you for your feedback! We appreciate your support.")
|
| 139 |
+
# Optionally, save feedback to a file or a database
|
| 140 |
+
with open("feedback.txt", "a") as f:
|
| 141 |
+
f.write(feedback + "\n")
|
| 142 |
|
| 143 |
st.chat_message('ai').write(
|
| 144 |
random.choice(APP_TEXT['ai_greetings'])
|
| 145 |
)
|
|
|
|
| 146 |
history = StreamlitChatMessageHistory(key=CHAT_MESSAGES)
|
| 147 |
|
| 148 |
if _is_it_refinement():
|
|
|
|
| 243 |
history.add_ai_message(response)
|
| 244 |
|
| 245 |
# The content has been generated as JSON
|
| 246 |
+
# There maybe trailing ``` at the end of the response -- remove them
|
| 247 |
+
# To be careful: ``` may be part of the content as well when code is generated
|
|
|
|
|
|
|
| 248 |
response_cleaned = text_helper.get_clean_json(response)
|
| 249 |
|
| 250 |
logger.info(
|
|
|
|
| 278 |
deck, the path may be to an empty file.
|
| 279 |
|
| 280 |
:param json_str: The content in *valid* JSON format.
|
| 281 |
+
:return: The path to the .pptx file or `None` in case of error.
|
| 282 |
"""
|
| 283 |
|
| 284 |
try:
|
|
|
|
| 306 |
except RecursionError:
|
| 307 |
st.error(
|
| 308 |
'Encountered an error while parsing JSON...'
|
| 309 |
+
'the slide cannot be created, unfortunately ☹'
|
| 310 |
'\nPlease try again later.'
|
| 311 |
)
|
| 312 |
+
logger.error('Caught RecursionError while parsing JSON. Cannot generate the slidemaker!')
|
| 313 |
|
| 314 |
return None
|
| 315 |
except Exception:
|
| 316 |
st.error(
|
| 317 |
'Encountered an error while parsing JSON...'
|
| 318 |
+
'the slide cannot be created, unfortunately ☹'
|
| 319 |
'\nPlease try again later.'
|
| 320 |
)
|
| 321 |
logger.error(
|
|
|
|
| 425 |
|
| 426 |
if __name__ == '__main__':
|
| 427 |
main()
|
| 428 |
+
|
|
|
|
|
|
|
|
|