bigPear commited on
Commit
20b388e
·
1 Parent(s): 38a35b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -19,23 +19,28 @@ model = model.eval()
19
  # history[-1][1] = response
20
  # return history
21
 
22
- def predict(input, history=None):
23
- if history is None:
24
- history = []
25
- response, history = model.chat(tokenizer, input, history)
26
- return history, history
27
 
28
  with gr.Blocks() as demo:
29
  chatbot = gr.Chatbot()
30
  msg = gr.Textbox()
31
  clear = gr.Button("Clear")
32
 
 
 
 
 
 
 
33
  def user(user_message, history):
34
  return "", history + [[user_message, None]]
35
 
36
  def bot(msg, history):
37
- # bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
38
- bot_message = predict(msg, history)
39
  history[-1][1] = ""
40
  for character in bot_message:
41
  history[-1][1] += character
 
19
  # history[-1][1] = response
20
  # return history
21
 
22
+ # def predict(input, history=None):
23
+ # if history is None:
24
+ # history = []
25
+ # response, history = model.chat(tokenizer, input, history)
26
+ # return response, history
27
 
28
  with gr.Blocks() as demo:
29
  chatbot = gr.Chatbot()
30
  msg = gr.Textbox()
31
  clear = gr.Button("Clear")
32
 
33
+ def predict(input, history=None):
34
+ if history is None:
35
+ history = []
36
+ response, history = model.chat(tokenizer, input, history)
37
+ return response, history
38
+
39
  def user(user_message, history):
40
  return "", history + [[user_message, None]]
41
 
42
  def bot(msg, history):
43
+ bot_message, _ = predict(msg, history)
 
44
  history[-1][1] = ""
45
  for character in bot_message:
46
  history[-1][1] += character