dennis-fast commited on
Commit
0334332
1 Parent(s): f0b1c44

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -1,4 +1,3 @@
1
- '''
2
  import transformers
3
  import gradio as gr
4
  import torch
@@ -28,8 +27,8 @@ def predict(input, history=[]):
28
 
29
  # convert the tokens to text, and then split the responses into lines
30
  response = tokenizer.decode(history[0]).split("<|endoftext|>")
31
- #response = [(response[i], response[i+1]) for i in range(0, len(response)-1, 2)] # convert to tuples of list
32
- response.remove("")
33
 
34
  # write some HTML
35
  html = "<div class='chatbot'>"
@@ -38,8 +37,8 @@ def predict(input, history=[]):
38
  html += "<div class='msg {}'> {}</div>".format(cls, msg)
39
  html += "</div>"
40
 
41
- #return response, history
42
- return html, history
43
 
44
  css = """
45
  .chatbox {display:flex;flex-direction:column}
@@ -50,14 +49,14 @@ css = """
50
  """
51
 
52
  gr.Interface(fn=predict,
53
- theme="default",
54
  title="DialoGPT-large",
55
  inputs=[gr.inputs.Textbox(placeholder="How are you?"), "state"],
56
  outputs=["html", "state"],
57
- css=css
58
  ).launch()
59
- '''
60
 
 
61
  from transformers import AutoModelForCausalLM, AutoTokenizer
62
  import torch
63
 
@@ -102,4 +101,5 @@ gr.Interface(fn=predict,
102
  inputs=[gr.inputs.Textbox(placeholder="How are you?"), "state"],
103
  outputs=["html", "state"],
104
  css=css).launch()
 
105
 
 
1
  import transformers
2
  import gradio as gr
3
  import torch
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'>"
37
  html += "<div class='msg {}'> {}</div>".format(cls, msg)
38
  html += "</div>"
39
 
40
+ return response, history
41
+ #return html, history
42
 
43
  css = """
44
  .chatbox {display:flex;flex-direction:column}
49
  """
50
 
51
  gr.Interface(fn=predict,
52
+ theme="grass",
53
  title="DialoGPT-large",
54
  inputs=[gr.inputs.Textbox(placeholder="How are you?"), "state"],
55
  outputs=["html", "state"],
56
+ #css=css
57
  ).launch()
 
58
 
59
+ '''
60
  from transformers import AutoModelForCausalLM, AutoTokenizer
61
  import torch
62
 
101
  inputs=[gr.inputs.Textbox(placeholder="How are you?"), "state"],
102
  outputs=["html", "state"],
103
  css=css).launch()
104
+ '''
105