elapt1c commited on
Commit
5bc59eb
·
verified ·
1 Parent(s): d968e4a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -95,8 +95,15 @@ def chat_with_model(user_input, history=[]):
95
  split_response = response.split(tokenizer.eos_token)
96
  bot_response = split_response[-1].strip()
97
 
 
98
  history.append((user_input, bot_response))
99
- return bot_response, history
 
 
 
 
 
 
100
 
101
  def history_to_transformer_format(history):
102
  """Convert gradio history to a list of strings for transformer input."""
 
95
  split_response = response.split(tokenizer.eos_token)
96
  bot_response = split_response[-1].strip()
97
 
98
+ # Explicitly format history as list of tuples:
99
  history.append((user_input, bot_response))
100
+
101
+ # Reformat history for Gradio Chatbot - Ensure tuples within a list
102
+ chatbot_history = []
103
+ for turn in history:
104
+ chatbot_history.append(turn) # Each turn is already a tuple (user_msg, bot_msg)
105
+
106
+ return bot_response, chatbot_history # Return chatbot_history for Gradio
107
 
108
  def history_to_transformer_format(history):
109
  """Convert gradio history to a list of strings for transformer input."""