Matthew Hollings commited on
Commit
26a02ca
1 Parent(s): 8b85762

Add a reset button.

Browse files
Files changed (2) hide show
  1. .gitignore +2 -1
  2. app.py +31 -13
.gitignore CHANGED
@@ -3,4 +3,5 @@ flagged/
3
  gutenberg-dammit-files-v002.zip
4
  tmp_trainer
5
  *.gz
6
- gpt2-poetry-model
 
 
3
  gutenberg-dammit-files-v002.zip
4
  tmp_trainer
5
  *.gz
6
+ gpt2-poetry-model
7
+ .ipynb_checkpoints
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import re
2
  import gradio as gr
3
  from transformers import pipeline
4
 
@@ -60,21 +59,40 @@ def add_to_lines(new_line):
60
  return html
61
 
62
 
63
- demo = gr.Interface(
64
- fn=add_to_lines,
65
- inputs=gr.Textbox(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  lines=1,
67
  value="The drought had lasted now for ten million years, and the reign of the terrible lizards had long since ended.",
68
- ),
69
- outputs="html",
70
- allow_flagging="never",
71
- )
 
 
72
 
 
 
73
 
74
  if __name__ == "__main__":
75
  demo.launch()
76
-
77
-
78
- def downloadtext():
79
- # somehow print the values from the list
80
- pass
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
59
  return html
60
 
61
 
62
+ def reset_all(new_line):
63
+ global source_lines
64
+ global generated_lines
65
+ source_lines = []
66
+ generated_lines = []
67
+
68
+ return None
69
+
70
+
71
+ # demo = gr.Interface(
72
+ # fn=add_to_lines,
73
+ # inputs=gr.Textbox(
74
+ # lines=1,
75
+ # value="The drought had lasted now for ten million years, and the reign of the terrible lizards had long since ended.",
76
+ # ),
77
+ # outputs="html",
78
+ # allow_flagging="never",
79
+ # )
80
+
81
+ demo = gr.Blocks()
82
+
83
+ with demo:
84
+ input = gr.Textbox(
85
  lines=1,
86
  value="The drought had lasted now for ten million years, and the reign of the terrible lizards had long since ended.",
87
+ )
88
+ with gr.Row():
89
+ add_line_button = gr.Button("Add line", variant="primary")
90
+ clear_all_button = gr.Button("Reset all")
91
+
92
+ output = gr.HTML()
93
 
94
+ add_line_button.click(fn=add_to_lines, inputs=input, outputs=output)
95
+ clear_all_button.click(fn=reset_all, inputs=input, outputs=output)
96
 
97
  if __name__ == "__main__":
98
  demo.launch()