Spaces:
Sleeping
Sleeping
Update src/app.py
Browse files- src/app.py +17 -17
src/app.py
CHANGED
|
@@ -300,24 +300,24 @@ with tab2:
|
|
| 300 |
# The token progress bar will be handled inside the prompt logic based on input length
|
| 301 |
|
| 302 |
with c3:
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
|
| 320 |
-
|
| 321 |
|
| 322 |
# --- DISPLAY CONVERSATION HISTORY ---
|
| 323 |
for message in st.session_state.messages:
|
|
|
|
| 300 |
# The token progress bar will be handled inside the prompt logic based on input length
|
| 301 |
|
| 302 |
with c3:
|
| 303 |
+
# --- NEW FEATURE: DOWNLOAD CHAT ---
|
| 304 |
+
# Convert history to a readable string
|
| 305 |
+
chat_log = ""
|
| 306 |
+
for msg in st.session_state.messages:
|
| 307 |
+
role = "USER" if msg['role'] == 'user' else "ASSISTANT"
|
| 308 |
+
chat_log += f"[{role}]: {msg['content']}\n\n"
|
| 309 |
+
|
| 310 |
+
# Only show button if there is history to save
|
| 311 |
+
if chat_log:
|
| 312 |
+
st.download_button(
|
| 313 |
+
label="💾 Save Chat",
|
| 314 |
+
data=chat_log,
|
| 315 |
+
file_name="mission_log.txt",
|
| 316 |
+
mime="text/plain",
|
| 317 |
+
help="Download the current conversation history."
|
| 318 |
+
)
|
| 319 |
|
| 320 |
+
st.divider()
|
| 321 |
|
| 322 |
# --- DISPLAY CONVERSATION HISTORY ---
|
| 323 |
for message in st.session_state.messages:
|