Spaces:
Build error
Build error
Commit
·
7608b65
1
Parent(s):
e1772ff
Update app.py
Browse files
app.py
CHANGED
@@ -27,15 +27,25 @@ def predict(input, history=[]):
|
|
27 |
|
28 |
# convert the tokens to text, and then split the responses into lines
|
29 |
response = tokenizer.decode(history[0]).split("<|endoftext|>")
|
30 |
-
response = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)] # convert to tuples of list
|
31 |
-
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
gr.Interface(fn=predict,
|
36 |
title="DialoGPT-large",
|
37 |
inputs=["text", "state"],
|
38 |
-
outputs=["
|
39 |
-
|
40 |
-
|
41 |
|
|
|
27 |
|
28 |
# convert the tokens to text, and then split the responses into lines
|
29 |
response = tokenizer.decode(history[0]).split("<|endoftext|>")
|
30 |
+
#response = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)] # convert to tuples of list
|
31 |
+
response.remove("")
|
32 |
|
33 |
+
# write some HTML
|
34 |
+
html = "<div class='chatbot'>"
|
35 |
+
for m, msg in enumerate(response):
|
36 |
+
cls = "user" if m%2 == 0 else "bot"
|
37 |
+
html += "<div class='msg {}'> {}</div>".format(cls, msg)
|
38 |
+
html += "</div>"
|
39 |
+
|
40 |
+
#return response, history
|
41 |
+
return html, history
|
42 |
+
|
43 |
+
chatbot = gr.Chatbot(color_map=("green", "gray"))
|
44 |
|
45 |
gr.Interface(fn=predict,
|
46 |
title="DialoGPT-large",
|
47 |
inputs=["text", "state"],
|
48 |
+
outputs=["html", "state"],
|
49 |
+
css=css
|
50 |
+
).launch()
|
51 |
|