Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -192,6 +192,28 @@ with st.sidebar:
|
|
192 |
|
193 |
st.divider()
|
194 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
# Clear controls
|
196 |
if st.button("Clear Chat", use_container_width=True, type="secondary"):
|
197 |
clear_chat_history()
|
|
|
192 |
|
193 |
st.divider()
|
194 |
|
195 |
+
# View History
|
196 |
+
if st.button("View History File", use_container_width=True):
|
197 |
+
if os.path.exists(HISTORY_FILE):
|
198 |
+
with open(HISTORY_FILE, 'r', encoding='utf-8') as f:
|
199 |
+
history_content = f.read()
|
200 |
+
st.text_area("Chat History (JSON)", history_content, height=200)
|
201 |
+
else:
|
202 |
+
st.warning("No history file found")
|
203 |
+
|
204 |
+
# Download History
|
205 |
+
if os.path.exists(HISTORY_FILE):
|
206 |
+
with open(HISTORY_FILE, 'rb') as f:
|
207 |
+
st.download_button(
|
208 |
+
label="Download History",
|
209 |
+
data=f.read(),
|
210 |
+
file_name=f"chat_history_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json",
|
211 |
+
mime="application/json",
|
212 |
+
use_container_width=True
|
213 |
+
)
|
214 |
+
|
215 |
+
st.divider()
|
216 |
+
|
217 |
# Clear controls
|
218 |
if st.button("Clear Chat", use_container_width=True, type="secondary"):
|
219 |
clear_chat_history()
|