kevineen commited on
Commit
37be2c9
1 Parent(s): 77920ff

ボタン初期無効化

Browse files
Files changed (4) hide show
  1. .gitignore +3 -1
  2. README.md +2 -4
  3. run.py +138 -176
  4. script/custom.js +1 -10
.gitignore CHANGED
@@ -167,4 +167,6 @@ run_2.py
167
  run_3.py
168
  run_4.py
169
  backup.py
170
- idea.txt
 
 
 
167
  run_3.py
168
  run_4.py
169
  backup.py
170
+ idea.txt
171
+
172
+ dataclass.py
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: 💬
4
  colorFrom: yellow
5
  colorTo: purple
6
  sdk: gradio
7
- app_file: run.py
8
  pinned: false
9
  license: apache-2.0
10
 
@@ -17,6 +17,4 @@ hf_oauth_scopes:
17
  - write-repos
18
  - manage-repos
19
  - inference-api
20
- ---
21
-
22
- An example chatbot using [Gradio](https://gradio.app), [`huggingface_hub`](https://huggingface.co/docs/huggingface_hub/v0.22.2/en/index), and the [Hugging Face Inference API](https://huggingface.co/docs/api-inference/index).
 
4
  colorFrom: yellow
5
  colorTo: purple
6
  sdk: gradio
7
+ app_file: run.py # HotReloadデバッグのため、app.pyから変更中 gradio run.pyで開発中は変更の監視が可能
8
  pinned: false
9
  license: apache-2.0
10
 
 
17
  - write-repos
18
  - manage-repos
19
  - inference-api
20
+ ---
 
 
run.py CHANGED
@@ -1,60 +1,61 @@
1
  import os
2
- from huggingface_hub import HfFolder
3
-
4
- # HF_Spaceでプライベート関連にアクセスするための環境変数
5
- HF_TOKEN = os.getenv("HF_TOKEN")
6
- if HF_TOKEN:
7
- HfFolder.save_token(HF_TOKEN)
8
- else:
9
- print("Warning: HF_TOKEN not found. Please set it in your Space secrets.")
10
 
11
  import json
12
  import datetime
13
  from pathlib import Path
14
  import uuid
15
-
16
  from typing import Tuple
17
- from datasets import load_dataset, Dataset, concatenate_datasets
18
  import pandas as pd
19
 
20
  import gradio as gr
 
21
  from huggingface_hub import CommitScheduler
 
22
 
23
- # HF保存先
 
 
 
 
 
 
 
 
 
24
  output_dataset = [
25
  "kevineen/test_phase2", # 出力テスト
26
- # "kanhatakeyama/ftdata", # 出力読込テスト
27
  ]
28
 
29
- # アノテーションするデータセット
30
  annotation_dataset_list = [
31
- # "hatakeyama-llm-team/WikiBookJa", # 良・悪のみ
32
  "hatakeyama-llm-team/AutoGeneratedJapaneseQA",
33
  "hatakeyama-llm-team/AutoGeneratedJapaneseQA-other",
34
  "kanhatakeyama/AutoWikiQA",
35
  "kanhatakeyama/ChatbotArenaJaMixtral8x22b",
36
  "kanhatakeyama/OrcaJaMixtral8x22b",
37
- # "kanhatakeyama/AutoMultiTurnByMixtral8x22b", # マルチターン
38
  "kanhatakeyama/LogicalDatasetsByMixtral8x22b",
39
- "susumuota/SyntheticTextWikiTranslate-askllm-v1", # Ask-LLM
 
 
 
40
  ]
41
 
 
 
42
  annotation_file = Path("user_annotation/") / f"data_{uuid.uuid4()}.json"
43
  annotated_folder = annotation_file.parent
44
 
45
- # 要テスト 保存先はどこか、作業再開後などのデータの保存がどうなるか
46
- # ~/.cache/huggingfaceに(ローカル)
47
- # loginはどうなる?
48
  scheduler = CommitScheduler(
49
- repo_id="kevineen/test_phase2",
50
  repo_type="dataset",
51
  folder_path=annotated_folder,
52
- path_in_repo="data",
53
  private=True,
54
- every=5, # 5分毎にアップロード HF_Docの最低推奨値
55
  )
56
 
57
- # CommitScheduler (HFへのデータアップロード
58
  def save_annotation(
59
  dataset_name: str,
60
  dataset_id : int,
@@ -82,13 +83,11 @@ def save_annotation(
82
  'answer_text_2': [answer_text_2]
83
  })], ignore_index=True).reset_index(drop=True)
84
 
85
- print(annotated_dataset.value)
86
-
87
  # 書き込み
88
  # with scheduler.lock:
89
  with annotation_file.open("a") as f:
90
  data_to_write = {
91
- "id": target_id.value,
92
  "datetime": str(datetime.datetime.now().isoformat()),
93
  "dataset_name": dataset_name,
94
  "dataset_id": dataset_id,
@@ -101,12 +100,10 @@ def save_annotation(
101
  "is_proofreading_2": is_proofreading_2,
102
  "answer_text_2": answer_text_2,
103
  }
104
- # print(data_to_write)
105
  f.write(json.dumps(data_to_write))
106
  f.write("\n")
107
 
108
-
109
- # Session State (ブラウザ単位の変数管理)
110
 
111
  # UIのEnable/Disable用State
112
  is_selected_dataset = gr.State(False)
@@ -118,12 +115,9 @@ dropdown_dataset_list = gr.State(value = annotation_dataset_list)
118
  select_dropdown_dataset = gr.State(dropdown_dataset_list.value[0])
119
  select_dataset = gr.State(None) # 現在のデータセット
120
  select_dataset_total_len = gr.State(0) # 現在のデータセットの長さ
121
- select_idx = gr.State(0) # 現在のインデックス
122
  random_mode = gr.State(False)
123
 
124
- target_dataset_name = gr.State(output_dataset[0]) # 出力先データセット名
125
- target_dataset = gr.State(None) # 出力先データセット
126
-
127
  # 回答者がアノテーションしたデータセット
128
  annotated_dataset = gr.State(
129
  pd.DataFrame({
@@ -143,6 +137,8 @@ annotated_dataset = gr.State(
143
  initial_answer_text_1 = gr.State("") # 回答1を整形したかチェック用
144
  initial_answer_text_2 = gr.State("") # 回答2を整形したかチェック用
145
 
 
 
146
  you_dataset_id = gr.State(0) # 回答者がアノテーションしているデータのID
147
  target_id = gr.State(0) # 出力先のデータセットをチェックし、末尾IDを追加
148
  dataset_name = gr.State("") # 編集に使用したデータセット名
@@ -156,17 +152,6 @@ answer_text_1 = gr.State("") # answer_1 回答
156
  is_proofreading_2 = gr.State(False) # 回答2を整形したか_2
157
  answer_text_2 = gr.State("") # answer_2 回答
158
 
159
- labeled_output_dataset = gr.State(None) # 出力用
160
-
161
- # テーマの状態
162
- theme_ = gr.themes.Default()
163
-
164
- # 後のCSSデザイン変更用
165
- def load_css():
166
- with open("style.css", "r") as file:
167
- css_content = file.read()
168
- return css_content
169
-
170
  # ユーザー名表示
171
  def hello(profile: gr.OAuthProfile | None) -> Tuple[str, str]:
172
  if profile is None:
@@ -174,43 +159,22 @@ def hello(profile: gr.OAuthProfile | None) -> Tuple[str, str]:
174
  who.value = profile.username
175
  return f'{profile.username} さん、よろしくお願いいたします。', who.value
176
 
177
-
178
  # データ読み込み
179
 
180
  # データの保存処理
181
 
182
  # アノテーションの追加処理
183
 
184
- # UI処理
185
-
186
-
187
- # HFにアップロードするためのデータセットに変換する
188
- def upload_to_huggingFace(pd_dataset: pd.DataFrame):
189
- # 出力先のデータセットを読み込む
190
- target_dataset = load_dataset(target_dataset_name.value)["train"]
191
- target_dataset = target_dataset.to_pandas().drop('Unnamed: 0', axis=1)
192
-
193
- # TODO 取得したデータセットとアノテーションしたデータを比較し
194
- # 重複しているデータがなければ追加する
195
- # 重複のチェックは、dataset と dataset_id と who が全て一致するものを探す
196
- # 重複していたら、その行を更新する
197
-
198
- # TODO 前処理
199
- # initial_answer_text_1とanswer_text_1を比較し、異なる場合はis_proofreading_1をTrueにする
200
- # initial_answer_text_2とanswer_text_2を比較し、異なる場合はis_proofreading_2をTrueにする
201
- # is_proofreading_1, is_proofreading_2 が False の場合、answer_text_1, answer_text_2 は空文字列にする
202
-
203
- preprocessed_pd_dataset = pd_dataset
204
 
205
- # Datasetに変換
206
- from_update_dataset = Dataset.from_pandas(preprocessed_pd_dataset)
207
-
208
- # 結合する
209
- updated_dataset = concatenate_datasets([from_update_dataset, dataset_name])
210
-
211
- # TODO アップロード
212
- updated_dataset.save_to_disk(target_dataset_name.value)
213
 
 
 
 
 
 
214
 
215
  with gr.Blocks(theme = theme_, css = load_css()) as demo:
216
 
@@ -246,123 +210,121 @@ with gr.Blocks(theme = theme_, css = load_css()) as demo:
246
 
247
  gr_data_load_btn = gr.Button("② データセットを読み込む")
248
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  # データセットロード
250
- def dataset_load_fn() -> Tuple[str, str, str, str]:
251
- print("-----Loading Dataset-----")
252
  select_dataset.value = load_dataset(select_dropdown_dataset.value)
253
  select_idx.value = 0
254
  select_dataset_total_len.value = select_dataset.value["train"].num_rows
255
-
256
- return "現在のidx" + str(select_idx.value) + " / " + str(select_dataset_total_len.value), \
 
 
257
  select_dataset.value["train"][select_idx.value]["question"], \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  select_dataset.value["train"][select_idx.value]["answer"], \
259
  select_dataset.value["train"][select_idx.value]["question"], \
260
  select_dataset.value["train"][select_idx.value]["answer"]
261
-
262
-
263
- with gr.Tab("③ シンプルモード(良い・悪いのみ選択)"):
264
- with gr.Column():
265
- with gr.Row(equal_height=True):
266
- good_btn = gr.Button("良い")
267
- bad_btn = gr.Button("悪い")
268
-
269
- with gr.Row():
270
- gr_current_idx = gr.Markdown("現在のインデックス")
271
- gr_total_length = gr.Markdown("データセットのトータル")
272
- gr.Checkbox(False, label="ランダム取得モード")
273
-
274
- gr_question_text_1 = gr.Textbox(label="質問: ",lines=5, interactive=False)
275
- gr_answer_text_1 = gr.Textbox(label="回答: 訂正頂けると品質が上がります。", lines=20, interactive=True)
276
-
277
- with gr.Tab("③ 丁寧モード(5段階評価・文章校正)"):
278
 
279
- gr_question_text_2 = gr.Textbox(label="質問: ",lines=5, interactive=False)
280
-
281
- gr_score_slider = gr.Slider(1, 5, label="回答のスコア: 1-5 (1:大変悪い、2:悪い、3:普通、4:良い、5:大変良い)", step=1, value=score.value, interactive=True)
282
-
283
- gr_score_slider.change(
284
- print("change")
285
  )
286
 
287
- gr_submit_btn = gr.Button("決定")
288
-
289
- gr_answer_text_2 = gr.Textbox(label="回答: 訂正頂けると品質が上がります。", lines=20, interactive=True)
290
-
291
- gr_data_load_btn.click(
292
- dataset_load_fn,
293
- inputs=None,
294
- outputs=[gr_current_idx, gr_question_text_1, gr_answer_text_1, gr_question_text_2, gr_answer_text_2]
295
- )
 
 
296
 
297
- def good_click() -> Tuple[str, str, str, str]:
298
- # 値更新
299
- good.value = True
300
- bad.value = False
301
-
302
- # 表示更新
303
- select_idx.value += 1
304
- target_id.value += 1
305
- gr_question_text_1.value = select_dataset.value["train"][select_idx.value]["question"]
306
-
307
- # データセットに追加
308
- save_annotation(
309
- select_dropdown_dataset.value,
310
- target_id.value,
311
- who.value,
312
- good.value,
313
- bad.value,
314
- score.value,
315
- is_proofreading_1.value,
316
- answer_text_1.value,
317
- is_proofreading_2.value,
318
- answer_text_2.value
319
  )
320
-
321
- # target_id.value += target_id.value
322
- print(annotated_dataset.value)
323
-
324
- return "現在のidx" + str(select_idx.value) + " / " + str(select_dataset_total_len.value), \
325
- select_dataset.value["train"][select_idx.value]["question"], \
326
- select_dataset.value["train"][select_idx.value]["answer"], \
327
- select_dataset.value["train"][select_idx.value]["question"], \
328
- select_dataset.value["train"][select_idx.value]["answer"]
329
-
330
- good_btn.click(
331
- good_click,
332
- inputs=[],
333
- outputs=[gr_current_idx, gr_question_text_1, gr_answer_text_1, gr_question_text_2, gr_answer_text_2]
334
- )
335
-
336
- def bad_click() -> Tuple[str, str, str, str]:
337
- good.value = False
338
- bad.value = True
339
-
340
- select_idx.value += 1
341
 
342
- gr_question_text_1.value = select_dataset.value["train"][select_idx.value]["question"]
343
- return "現在のidx" + str(select_idx.value) + " / " + str(select_dataset_total_len.value), \
344
- select_dataset.value["train"][select_idx.value]["question"], \
345
- select_dataset.value["train"][select_idx.value]["answer"], \
346
- select_dataset.value["train"][select_idx.value]["question"], \
347
- select_dataset.value["train"][select_idx.value]["answer"]
348
-
349
- bad_btn.click(
350
- bad_click,
351
- inputs=[],
352
- outputs=[gr_current_idx, gr_question_text_1, gr_answer_text_1, gr_question_text_2, gr_answer_text_2]
353
- )
354
-
355
- # tab.selectでのデータ更新がうまくいかず、、、
356
- # TODO tab切り替えで、アノテ済みの一覧を表示する
357
- # with gr.Tab("アノテ済みデータセット(管理画面)"):
358
-
359
- # CommitSchedulerに変更したのでJsonファイルを読込
360
-
361
- # gr.Textbox(target_dataset_name.value, label="出力先データセット名", interactive=False)
362
- # gr_annotation = gr.DataFrame(annotated_dataset.value)
363
- # gr.Button("データを送信する")
364
-
365
- # タブを切り替えた時にデータ表示を更新する
366
 
367
  if __name__ == "__main__":
368
  demo.launch()
 
1
  import os
 
 
 
 
 
 
 
 
2
 
3
  import json
4
  import datetime
5
  from pathlib import Path
6
  import uuid
 
7
  from typing import Tuple
8
+
9
  import pandas as pd
10
 
11
  import gradio as gr
12
+ from datasets import load_dataset
13
  from huggingface_hub import CommitScheduler
14
+ from huggingface_hub import HfFolder
15
 
16
+ # HF_Spaceでプライベート関連にアクセスするための環境変数
17
+ # SecretKey をSpaceのSettingsに設定
18
+ HF_TOKEN = os.getenv("HF_TOKEN")
19
+ if HF_TOKEN:
20
+ HfFolder.save_token(HF_TOKEN)
21
+ else:
22
+ print("Warning: HF_TOKEN not found. Please set it in your Space secrets.")
23
+
24
+ # HFデータセット アップロード先
25
+ # (切替てテストする用に配列)
26
  output_dataset = [
27
  "kevineen/test_phase2", # 出力テスト
 
28
  ]
29
 
30
+ # アノテーション対象データセット
31
  annotation_dataset_list = [
 
32
  "hatakeyama-llm-team/AutoGeneratedJapaneseQA",
33
  "hatakeyama-llm-team/AutoGeneratedJapaneseQA-other",
34
  "kanhatakeyama/AutoWikiQA",
35
  "kanhatakeyama/ChatbotArenaJaMixtral8x22b",
36
  "kanhatakeyama/OrcaJaMixtral8x22b",
 
37
  "kanhatakeyama/LogicalDatasetsByMixtral8x22b",
38
+ # データ形式未対応(対応予定
39
+ # "susumuota/SyntheticTextWikiTranslate-askllm-v1", # Ask-LLM
40
+ # "hatakeyama-llm-team/WikiBookJa", # 良・悪のみ
41
+ # "kanhatakeyama/AutoMultiTurnByMixtral8x22b", # マルチターン
42
  ]
43
 
44
+ # Spaceの場合の保存先はCommitSchedulerのpath_in_repoフォルダ
45
+ # (ローカル開発の場合./user_annotationフォルダにjsonファイルが作成される)
46
  annotation_file = Path("user_annotation/") / f"data_{uuid.uuid4()}.json"
47
  annotated_folder = annotation_file.parent
48
 
 
 
 
49
  scheduler = CommitScheduler(
50
+ repo_id=output_dataset[0],
51
  repo_type="dataset",
52
  folder_path=annotated_folder,
53
+ path_in_repo="data", # Spaceの場合の保存先フォルダー
54
  private=True,
55
+ every=5, # 5分毎にアップロード HuggingFAce_Documentの最低推奨値
56
  )
57
 
58
+ # CommitScheduler (HFへのデータアップロード
59
  def save_annotation(
60
  dataset_name: str,
61
  dataset_id : int,
 
83
  'answer_text_2': [answer_text_2]
84
  })], ignore_index=True).reset_index(drop=True)
85
 
 
 
86
  # 書き込み
87
  # with scheduler.lock:
88
  with annotation_file.open("a") as f:
89
  data_to_write = {
90
+ # "id": , CommitSchedulerだと取得して末尾idを付与することが無理?
91
  "datetime": str(datetime.datetime.now().isoformat()),
92
  "dataset_name": dataset_name,
93
  "dataset_id": dataset_id,
 
100
  "is_proofreading_2": is_proofreading_2,
101
  "answer_text_2": answer_text_2,
102
  }
 
103
  f.write(json.dumps(data_to_write))
104
  f.write("\n")
105
 
106
+ # Session State : (ブラウザ単位の変数管理) ===========================
 
107
 
108
  # UIのEnable/Disable用State
109
  is_selected_dataset = gr.State(False)
 
115
  select_dropdown_dataset = gr.State(dropdown_dataset_list.value[0])
116
  select_dataset = gr.State(None) # 現在のデータセット
117
  select_dataset_total_len = gr.State(0) # 現在のデータセットの長さ
118
+ select_idx = gr.State(0) # 現在のインデックス # ランダムモードにするなら不要?
119
  random_mode = gr.State(False)
120
 
 
 
 
121
  # 回答者がアノテーションしたデータセット
122
  annotated_dataset = gr.State(
123
  pd.DataFrame({
 
137
  initial_answer_text_1 = gr.State("") # 回答1を整形したかチェック用
138
  initial_answer_text_2 = gr.State("") # 回答2を整形したかチェック用
139
 
140
+ is_dataset_loaded = gr.State(False)
141
+
142
  you_dataset_id = gr.State(0) # 回答者がアノテーションしているデータのID
143
  target_id = gr.State(0) # 出力先のデータセットをチェックし、末尾IDを追加
144
  dataset_name = gr.State("") # 編集に使用したデータセット名
 
152
  is_proofreading_2 = gr.State(False) # 回答2を整形したか_2
153
  answer_text_2 = gr.State("") # answer_2 回答
154
 
 
 
 
 
 
 
 
 
 
 
 
155
  # ユーザー名表示
156
  def hello(profile: gr.OAuthProfile | None) -> Tuple[str, str]:
157
  if profile is None:
 
159
  who.value = profile.username
160
  return f'{profile.username} さん、よろしくお願いいたします。', who.value
161
 
 
162
  # データ読み込み
163
 
164
  # データの保存処理
165
 
166
  # アノテーションの追加処理
167
 
168
+ # UI処理 ========================================
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
170
+ # テーマの状態
171
+ theme_ = gr.themes.Default()
 
 
 
 
 
 
172
 
173
+ # 後のCSSデザイン変更用
174
+ def load_css():
175
+ with open("style.css", "r") as file:
176
+ css_content = file.read()
177
+ return css_content
178
 
179
  with gr.Blocks(theme = theme_, css = load_css()) as demo:
180
 
 
210
 
211
  gr_data_load_btn = gr.Button("② データセットを読み込む")
212
 
213
+
214
+ # 以下の部分を gr.Column で囲みます
215
+ with gr.Column() as content_column:
216
+ with gr.Tab("③ シンプル(良・悪)"):
217
+ with gr.Column():
218
+ with gr.Row(equal_height=True):
219
+ good_btn = gr.Button("良い", interactive=False)
220
+ bad_btn = gr.Button("悪い", interactive=False)
221
+
222
+ gr_question_text_1 = gr.Textbox(label="質問: ",lines=5, interactive=False)
223
+ gr_answer_text_1 = gr.Textbox(label="回答: 訂正頂けると品質が上がります。", lines=20, interactive=True)
224
+
225
+ with gr.Tab("③ 5段階評価"):
226
+
227
+ gr_question_text_2 = gr.Textbox(label="質問: ",lines=5, interactive=False)
228
+
229
+ gr_score_slider = gr.Slider(1, 5,
230
+ label="回答のスコア: 1-5 (1:大変悪い、2:悪い、3:普通、4:良い、5:大変良い)",
231
+ step=1,
232
+ value=score.value,
233
+ interactive=False)
234
+
235
+ gr_score_slider.change(
236
+ print("change")
237
+ )
238
+
239
+ gr_submit_btn = gr.Button("決定", interactive=False)
240
+
241
+ gr_answer_text_2 = gr.Textbox(label="回答: 訂正して頂けると品質が上がります。", lines=20, interactive=True)
242
+
243
  # データセットロード
244
+ def dataset_load_fn() -> Tuple[str, str, str, str, gr.update, gr.update, gr.update]:
 
245
  select_dataset.value = load_dataset(select_dropdown_dataset.value)
246
  select_idx.value = 0
247
  select_dataset_total_len.value = select_dataset.value["train"].num_rows
248
+ is_dataset_loaded.value = True
249
+
250
+ return select_dataset.value["train"][select_idx.value]["question"], \
251
+ select_dataset.value["train"][select_idx.value]["answer"], \
252
  select_dataset.value["train"][select_idx.value]["question"], \
253
+ select_dataset.value["train"][select_idx.value]["answer"], \
254
+ gr.update(interactive=True), \
255
+ gr.update(interactive=True), \
256
+ gr.update(interactive=True), \
257
+ gr.update(interactive=True)
258
+
259
+ gr_data_load_btn.click(
260
+ dataset_load_fn,
261
+ inputs=None,
262
+ outputs=[gr_question_text_1,
263
+ gr_answer_text_1,
264
+ gr_question_text_2,
265
+ gr_answer_text_2,
266
+ good_btn,
267
+ bad_btn,
268
+ gr_score_slider,
269
+ gr_submit_btn]
270
+ )
271
+
272
+ def good_click() -> Tuple[str, str, str, str]:
273
+ # 値更新
274
+ good.value = True
275
+ bad.value = False
276
+
277
+ # 表示更新
278
+ select_idx.value += 1
279
+ target_id.value += 1
280
+ gr_question_text_1.value = select_dataset.value["train"][select_idx.value]["question"]
281
+
282
+ # データセットに追加
283
+ save_annotation(
284
+ select_dropdown_dataset.value,
285
+ target_id.value,
286
+ who.value,
287
+ good.value,
288
+ bad.value,
289
+ score.value,
290
+ is_proofreading_1.value,
291
+ answer_text_1.value,
292
+ is_proofreading_2.value,
293
+ answer_text_2.value
294
+ )
295
+
296
+ return select_dataset.value["train"][select_idx.value]["question"], \
297
  select_dataset.value["train"][select_idx.value]["answer"], \
298
  select_dataset.value["train"][select_idx.value]["question"], \
299
  select_dataset.value["train"][select_idx.value]["answer"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
 
301
+ good_btn.click(
302
+ good_click,
303
+ inputs=[],
304
+ outputs=[gr_question_text_1, gr_answer_text_1, gr_question_text_2, gr_answer_text_2]
 
 
305
  )
306
 
307
+ def bad_click() -> Tuple[str, str, str, str]:
308
+ good.value = False
309
+ bad.value = True
310
+
311
+ select_idx.value += 1
312
+
313
+ gr_question_text_1.value = select_dataset.value["train"][select_idx.value]["question"]
314
+ return select_dataset.value["train"][select_idx.value]["question"], \
315
+ select_dataset.value["train"][select_idx.value]["answer"], \
316
+ select_dataset.value["train"][select_idx.value]["question"], \
317
+ select_dataset.value["train"][select_idx.value]["answer"]
318
 
319
+ bad_btn.click(
320
+ bad_click,
321
+ inputs=[],
322
+ outputs=[gr_question_text_1, gr_answer_text_1, gr_question_text_2, gr_answer_text_2]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
 
325
+ # TODO tab切り替えで、アノテ済みの一覧を表示する
326
+ # with gr.Tab("アノテ済みデータセット(管理画面)"):
327
+ # タブを切り替えた時にデータ表示を更新する
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
 
329
  if __name__ == "__main__":
330
  demo.launch()
script/custom.js CHANGED
@@ -1,10 +1 @@
1
- function blockEnter(event) {
2
- document.addEventListener('DOMContentLoaded', (event) => {
3
- const textbox = document.getElementById('answer');
4
- textbox.addEventListener('keydown', (e) => {
5
- if (e.key === 'Enter') {
6
- e.preventDefault();
7
- }
8
- });
9
- });
10
- }
 
1
+ // TODO good.badボタンなどをショートカットキー対応させる