tenet commited on
Commit
c3ab621
Β·
verified Β·
1 Parent(s): 25e0351

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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
- user_msg = tokenizer.decode(st.session_state.history[i], skip_special_tokens=True)
41
- st.write(f"You: {user_msg}")
 
 
 
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")