research14 commited on
Commit
bbfeeba
·
1 Parent(s): b3f873e

adding demo launch

Browse files
Files changed (1) hide show
  1. app.py +34 -3
app.py CHANGED
@@ -15,11 +15,42 @@ iface = gr.Interface(
15
  theme=theme
16
  )
17
 
18
- with gr.Row():
19
- chatgot_btn = gr.Button("ChatGPT")
 
 
 
 
 
 
 
 
 
20
  llama_btn = gr.Button("LLaMA")
21
  vicuna_btn = gr.Button("Vicuna")
22
  alpaca_btn = gr.Button("Alpaca")
23
  flant5_btn = gr.Button("Flan-T5")
24
 
25
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  theme=theme
16
  )
17
 
18
+ iface.launch()
19
+
20
+ blocks = gr.Blocks()
21
+
22
+ with blocks as demo:
23
+ subject = gr.Textbox(placeholder="subject")
24
+ verb = gr.Radio(["ate", "loved", "hated"])
25
+ object = gr.Textbox(placeholder="object")
26
+
27
+ with gr.Row():
28
+ chatgpt_btn = gr.Button("ChatGPT")
29
  llama_btn = gr.Button("LLaMA")
30
  vicuna_btn = gr.Button("Vicuna")
31
  alpaca_btn = gr.Button("Alpaca")
32
  flant5_btn = gr.Button("Flan-T5")
33
 
34
+ def sentence_maker(w1, w2, w3):
35
+ return f"{w1} {w2} {w3}"
36
+
37
+ output1 = gr.Textbox(label="output 1")
38
+ output2 = gr.Textbox(label="verb")
39
+ output3 = gr.Textbox(label="verb reversed")
40
+ output4 = gr.Textbox(label="front end process and then send to backend")
41
+
42
+ btn.click(sentence_maker, [subject, verb, object], output1)
43
+ reverse_btn.click(
44
+ None, [subject, verb, object], output2, _js="(s, v, o) => o + ' ' + v + ' ' + s"
45
+ )
46
+ verb.change(lambda x: x, verb, output3, _js="(x) => [...x].reverse().join('')")
47
+ foo_bar_btn.click(None, [], subject, _js="(x) => x + ' foo'")
48
+
49
+ reverse_then_to_the_server_btn.click(
50
+ sentence_maker,
51
+ [subject, verb, object],
52
+ output4,
53
+ _js="(s, v, o) => [s, v, o].map(x => [...x].reverse().join(''))",
54
+ )
55
+
56
+ demo.launch()