| """ |
| PYTHON FILE FOR EXPORT CHAT FUNCTION |
| """ |
|
|
| import streamlit as st |
| from datetime import datetime |
|
|
|
|
| def export_chat(): |
| if 'generated' in st.session_state: |
| |
| |
| html_chat = "" |
| html_chat += '<html><head><title>ChatBOT Intelligenza Artificiale Italia ๐ง ๐ค๐ฎ๐น</title>' |
| |
| html_chat += '<style> .bot { background-color: #e5e5ea; padding: 10px; border-radius: 10px; margin: 10px; width: 50%; float: left; } .user { background-color: #dcf8c6; padding: 10px; border-radius: 10px; margin: 10px; width: 50%; float: right; } </style>' |
| html_chat += '</head><body>' |
| |
| html_chat += '<center><h1>ChatBOT Intelligenza Artificiale Italia ๐ง ๐ค๐ฎ๐น</h1>' |
| |
| html_chat += '<h3>๐ค Support the project with a donation for the development of new features ๐ค</h3>' |
| html_chat += '<br><a href="https://rebrand.ly/SupportAUTOGPTfree"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="PayPal donate button" /></a>' |
| |
| html_chat += '<br><br><h5>' + datetime.now().strftime("%d/%m/%Y %H:%M:%S") + '</h5></center><br><br>' |
| |
| |
| html_chat += '<div style="padding: 10px; border-radius: 10px; margin: 10px; width: 100%; float: left;">' |
| for i in range(len(st.session_state['generated'])-1, -1, -1): |
| html_chat += '<div class="bot">' + st.session_state["generated"][i] + '</div><br>' |
| html_chat += '<div class="user">' + st.session_state['past'][i] + '</div><br>' |
| html_chat += '</div>' |
| |
| html_chat += '<br><br><center><small>Thanks you for using our ChatBOT ๐ง ๐ค๐ฎ๐น</small>' |
| |
| html_chat += '<h6>๐ค Support the project with a donation for the development of new features ๐ค</h6>' |
| html_chat += '<br><a href="https://rebrand.ly/SupportAUTOGPTfree"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="PayPal donate button" /></a><center>' |
| |
| html_chat += '</body></html>' |
| |
| |
| with open('chat.html', 'w') as f: |
| f.write(html_chat) |
| |
| st.download_button( |
| label="๐ Download chat", |
| data=html_chat, |
| file_name='chat.html', |
| mime='text/html' |
| ) |