""" PYTHON FILE FOR EXPORT CHAT FUNCTION """ import streamlit as st from datetime import datetime def export_chat(): if 'generated' in st.session_state: # save message in reverse order frist message always bot # the chat is stored in a html file format html_chat = "" html_chat += 'ChatBOT Intelligenza Artificiale Italia 🧠🤖🇮🇹' #create two simply css box for bot and user like whatsapp html_chat += '' html_chat += '' #add header html_chat += '

ChatBOT Intelligenza Artificiale Italia 🧠🤖🇮🇹

' #add link for danation html_chat += '

🤗 Support the project with a donation for the development of new features 🤗

' html_chat += '
PayPal donate button' #add subheader with date and time html_chat += '

' + datetime.now().strftime("%d/%m/%Y %H:%M:%S") + '


' #add chat #add solid container html_chat += '
' for i in range(len(st.session_state['generated'])-1, -1, -1): html_chat += '
' + st.session_state["generated"][i] + '

' html_chat += '
' + st.session_state['past'][i] + '

' html_chat += '
' #add footer html_chat += '

Thanks you for using our ChatBOT 🧠🤖🇮🇹' #add link for danation html_chat += '
🤗 Support the project with a donation for the development of new features 🤗
' html_chat += '
PayPal donate button
' html_chat += '' #save file with open('chat.html', 'w') as f: f.write(html_chat) #download file st.download_button( label="📚 Download chat", data=html_chat, file_name='chat.html', mime='text/html' )