Update app.py
Browse files
app.py
CHANGED
@@ -34,11 +34,15 @@ if user_input:
|
|
34 |
st.session_state.history.append(tokenizer.encode(user_input + tokenizer.eos_token, return_tensors="pt"))
|
35 |
st.write(f"Bot: {response}")
|
36 |
|
37 |
-
# Show chat history
|
38 |
if st.session_state.history:
|
|
|
39 |
for i in range(len(st.session_state.history) - 1, -1, -1):
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
42 |
|
43 |
# --- File Upload and Processing ---
|
44 |
st.subheader("π Upload a File for AI to Read")
|
|
|
34 |
st.session_state.history.append(tokenizer.encode(user_input + tokenizer.eos_token, return_tensors="pt"))
|
35 |
st.write(f"Bot: {response}")
|
36 |
|
37 |
+
# Show chat history (safer decoding)
|
38 |
if st.session_state.history:
|
39 |
+
st.subheader("π Chat History")
|
40 |
for i in range(len(st.session_state.history) - 1, -1, -1):
|
41 |
+
try:
|
42 |
+
user_msg = tokenizer.decode(st.session_state.history[i][0].tolist(), skip_special_tokens=True)
|
43 |
+
st.write(f"You: {user_msg}")
|
44 |
+
except Exception as e:
|
45 |
+
st.warning(f"Could not decode history message: {e}")
|
46 |
|
47 |
# --- File Upload and Processing ---
|
48 |
st.subheader("π Upload a File for AI to Read")
|