Spaces:
Paused
Paused
Update app.py
Browse files
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 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 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 |
-
|
| 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
|