ysharma HF staff commited on
Commit
d5d74c4
1 Parent(s): 28497a4

update user input logic in predict

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -87,7 +87,9 @@ def parse_text(text):
87
 
88
 
89
  def predict(RETRY_FLAG, input, chatbot, max_length, top_p, temperature, history, past_key_values):
 
90
  chatbot.append((parse_text(input), ""))
 
91
  print(f"Inside predict, chatbot is - {chatbot}")
92
  print(f"Inside predict, history is - {history}")
93
  #if RETRY_FLAG:
@@ -98,6 +100,8 @@ def predict(RETRY_FLAG, input, chatbot, max_length, top_p, temperature, history,
98
  max_length=max_length, top_p=top_p,
99
  temperature=temperature):
100
  chatbot[-1] = (parse_text(input), parse_text(response))
 
 
101
 
102
  yield chatbot, history, past_key_values
103
 
@@ -170,13 +174,13 @@ def retry_last_answer(
170
  # Setting up a flag to capture a retry
171
  RETRY_FLAG = True
172
  # Getting last message from user
173
- user_input = history[-1][0]
174
  # Removing bot response from the history
175
  history.pop(-1)
176
 
177
  print(f"popped chatbot is - {chatbot}")
178
  print(f"popped history is - {history}")
179
- print(f"user_input is - {user_input}")
180
 
181
  yield from predict(
182
  RETRY_FLAG,
 
87
 
88
 
89
  def predict(RETRY_FLAG, input, chatbot, max_length, top_p, temperature, history, past_key_values):
90
+ print(f"Inside predict, user_input1 is - {user_input}")
91
  chatbot.append((parse_text(input), ""))
92
+ print(f"Inside predict, user_input1 is - {user_input}")
93
  print(f"Inside predict, chatbot is - {chatbot}")
94
  print(f"Inside predict, history is - {history}")
95
  #if RETRY_FLAG:
 
100
  max_length=max_length, top_p=top_p,
101
  temperature=temperature):
102
  chatbot[-1] = (parse_text(input), parse_text(response))
103
+ print(f"Inside predict, chatbot2 is - {chatbot}")
104
+ print(f"Inside predict, history2 is - {history}")
105
 
106
  yield chatbot, history, past_key_values
107
 
 
174
  # Setting up a flag to capture a retry
175
  RETRY_FLAG = True
176
  # Getting last message from user
177
+ #user_input = history[-1][0]
178
  # Removing bot response from the history
179
  history.pop(-1)
180
 
181
  print(f"popped chatbot is - {chatbot}")
182
  print(f"popped history is - {history}")
183
+ #print(f"user_input is - {user_input}")
184
 
185
  yield from predict(
186
  RETRY_FLAG,