ar0551 commited on
Commit
f142492
·
verified ·
1 Parent(s): 45bdf16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -36,10 +36,13 @@ def chat_with_bot(message, history):
36
  )
37
 
38
  decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
 
39
  response = decoded[len(prompt):].strip().split("\n")[0]
40
- # IMPORTANT: Append message pair as a list rather than a tuple.
41
  history.append([message, response])
42
- return response, history
 
 
43
 
44
  # Gradio ChatInterface expects fn(message, history) → (response, updated_history)
45
  gr.ChatInterface(
 
36
  )
37
 
38
  decoded = tokenizer.decode(outputs[0], skip_special_tokens=True)
39
+ # Extract assistant output after the prompt.
40
  response = decoded[len(prompt):].strip().split("\n")[0]
41
+ # Append the new conversation pair as a list of strings.
42
  history.append([message, response])
43
+ # Ensure that every conversation pair is a list of strings.
44
+ safe_history = [[str(u), str(b)] for u, b in history]
45
+ return response, safe_history
46
 
47
  # Gradio ChatInterface expects fn(message, history) → (response, updated_history)
48
  gr.ChatInterface(