svjack commited on
Commit
376fb29
·
1 Parent(s): 85ccecf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -41,6 +41,14 @@ with gr.Blocks(css = "custom.css") as demo:
41
  def user(user_message, history):
42
  return "", history + [[user_message, None]]
43
 
 
 
 
 
 
 
 
 
44
  def bot(history):
45
  '''
46
  bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
@@ -81,7 +89,7 @@ with gr.Blocks(css = "custom.css") as demo:
81
  )
82
 
83
  api_button.click(
84
- bot, chatbot, chatbot
85
  )
86
 
87
  clear.click(lambda: None, None, chatbot, queue=False)
 
41
  def user(user_message, history):
42
  return "", history + [[user_message, None]]
43
 
44
+ def bot_api(history):
45
+ history[-1][1] = ""
46
+ user_message = history[-1][0]
47
+ pred_iter = predict(user_message ,history)
48
+ for ele in pred_iter:
49
+ history[-1][1] = ele
50
+ return history
51
+
52
  def bot(history):
53
  '''
54
  bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
 
89
  )
90
 
91
  api_button.click(
92
+ bot_api, chatbot, chatbot
93
  )
94
 
95
  clear.click(lambda: None, None, chatbot, queue=False)