sheonhan commited on
Commit
fc40822
·
1 Parent(s): 14b974b

Update Gradio

Browse files
Files changed (2) hide show
  1. app.py +8 -31
  2. gradio-12.34.57.tar.gz +3 -0
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import subprocess
2
 
3
- commands = 'pip uninstall gradio -y; echo "pwd is: $(pwd)"; pip install ./gradio-12.34.56.tar.gz'
4
  subprocess.run(commands, shell=True)
5
 
6
  import json
@@ -18,34 +18,6 @@ from text_generation import Client
18
  from utils import get_full_text, wrap_html_code
19
 
20
  STYLE = """
21
-
22
- // for the last chat message on user side
23
- .message.user.latest {
24
- background-color: #F9FBE7;
25
- border: none;
26
- color: black;
27
- }
28
-
29
- // for the last chat message on bot side
30
- .message.bot.latest {
31
- background-color: #CE93D8;
32
- border: none;
33
- color: black;
34
- }
35
-
36
- // when user hovers on the two answers
37
- // generated by a language model
38
- .message.bot.latest:hover {
39
- box-shadow: 0 0 15px 0.5px #E1BEE7 !important;
40
- }
41
-
42
- .button:active {
43
- color: black;
44
- border: none;
45
- background-color: #CE93D8 !important;
46
- box-shadow: 0 0 15px 0.5px #F3E5F5 !important;
47
- }
48
-
49
  // "done" class is injected when user has made
50
  // decision between two candidate generated answers
51
  .message.bot.done {
@@ -82,7 +54,6 @@ if HF_TOKEN:
82
  shutil.rmtree("./data/")
83
  except:
84
  pass
85
-
86
  print("Pulling repo...")
87
  repo = Repository(
88
  local_dir="./data/",
@@ -136,6 +107,9 @@ def generate(user_message, history):
136
  option_a = wrap_html_code(response_1_text.strip())
137
  option_b = wrap_html_code(response_2_text.strip())
138
 
 
 
 
139
  history.append((user_message, option_a, option_b))
140
 
141
  return "", history
@@ -147,6 +121,9 @@ def save_labeling_data(last_dialogue, score):
147
  response_1,
148
  response_2,
149
  ) = last_dialogue
 
 
 
150
 
151
  file_name = "data.jsonl"
152
 
@@ -175,7 +152,7 @@ def on_select(event: gr.SelectData, history):
175
  threading.Thread(target=save_labeling_data, args=(history[-1], score)).start()
176
 
177
  del history[-1][index_to_delete]
178
- return (gr.update(interactive=True), history)
179
 
180
 
181
  with gr.Blocks(css=STYLE) as demo:
 
1
  import subprocess
2
 
3
+ commands = 'pip uninstall gradio -y; echo "pwd is: $(pwd)"; pip install ./gradio-12.34.57.tar.gz'
4
  subprocess.run(commands, shell=True)
5
 
6
  import json
 
18
  from utils import get_full_text, wrap_html_code
19
 
20
  STYLE = """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  // "done" class is injected when user has made
22
  // decision between two candidate generated answers
23
  .message.bot.done {
 
54
  shutil.rmtree("./data/")
55
  except:
56
  pass
 
57
  print("Pulling repo...")
58
  repo = Repository(
59
  local_dir="./data/",
 
107
  option_a = wrap_html_code(response_1_text.strip())
108
  option_b = wrap_html_code(response_2_text.strip())
109
 
110
+ option_a = f"A: {option_a}"
111
+ option_b = f"B: {option_b}"
112
+
113
  history.append((user_message, option_a, option_b))
114
 
115
  return "", history
 
121
  response_1,
122
  response_2,
123
  ) = last_dialogue
124
+
125
+ response_1 = response_1[3:] # Remove label "A: "
126
+ response_2 = response_2[3:] # Remove label "B: "
127
 
128
  file_name = "data.jsonl"
129
 
 
152
  threading.Thread(target=save_labeling_data, args=(history[-1], score)).start()
153
 
154
  del history[-1][index_to_delete]
155
+ return history
156
 
157
 
158
  with gr.Blocks(css=STYLE) as demo:
gradio-12.34.57.tar.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13d0034be155506fcbe29694b69874ea47965c78dd90860ede4aba9c1e9c6269
3
+ size 11061689