Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -365,19 +365,39 @@ def update_sample_view(dimension_title):
|
|
| 365 |
return empty_updates + slider_empty_updates
|
| 366 |
|
| 367 |
def update_test_dimension_view(d_idx, selections):
|
| 368 |
-
dimension = DIMENSIONS_DATA[d_idx]
|
| 369 |
progress_d = f"维度 {d_idx + 1} / {len(DIMENSIONS_DATA)}: **{dimension['title']}**"
|
| 370 |
|
| 371 |
existing_scores = selections.get(dimension['title'], {})
|
|
|
|
| 372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
slider_updates = []
|
| 374 |
for i in range(MAX_SUB_DIMS):
|
| 375 |
-
if i < len(
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
slider_updates.append(gr.update(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 379 |
else:
|
| 380 |
-
slider_updates.append(gr.update(visible=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
|
| 382 |
prev_btn_update = gr.update(interactive=(d_idx > 0))
|
| 383 |
next_btn_update = gr.update(
|
|
@@ -885,21 +905,21 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
|
|
| 885 |
gr.Markdown("--- \n ### 请为对话中的回应者(非发起者)针对以下特征打分 (0-5分。0-特征无体现;1-机器;3-特征无偏向;5-人类)")
|
| 886 |
|
| 887 |
test_sliders = [gr.Slider(minimum=1, maximum=5, step=1, label=f"Sub-dim {i+1}", visible=False, interactive=True, show_label = True) for i in range(MAX_SUB_DIMS)]
|
| 888 |
-
print(MAX_SUB_DIMS)
|
| 889 |
-
# slider_index = 0 # 对应 test_sliders 的索引
|
| 890 |
-
# done = False
|
| 891 |
-
for dim in DIMENSIONS_DATA:
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
slider.minimum = 1
|
| 903 |
# if any(keyword in desc for keyword in SPECIAL_KEYWORDS):# 所以这里用any做字符串匹配
|
| 904 |
# slider.minimum = 0
|
| 905 |
# else:
|
|
|
|
| 365 |
return empty_updates + slider_empty_updates
|
| 366 |
|
| 367 |
def update_test_dimension_view(d_idx, selections):
|
| 368 |
+
# dimension = DIMENSIONS_DATA[d_idx]
|
| 369 |
progress_d = f"维度 {d_idx + 1} / {len(DIMENSIONS_DATA)}: **{dimension['title']}**"
|
| 370 |
|
| 371 |
existing_scores = selections.get(dimension['title'], {})
|
| 372 |
+
|
| 373 |
|
| 374 |
+
slider_updates = []
|
| 375 |
+
dim_data = DIMENSIONS_DATA[d_idx]
|
| 376 |
+
sub_dims = dim_data["sub_dims"]
|
| 377 |
+
dim_title = dim_data["title"]
|
| 378 |
+
|
| 379 |
slider_updates = []
|
| 380 |
for i in range(MAX_SUB_DIMS):
|
| 381 |
+
if i < len(sub_dims):
|
| 382 |
+
desc = sub_dims[i]
|
| 383 |
+
name = desc.split(":")[0].strip()
|
| 384 |
+
slider_updates.append(gr.update(
|
| 385 |
+
visible=True,
|
| 386 |
+
label=desc,
|
| 387 |
+
minimum=1 if name in SPECIAL_KEYWORDS else 0,
|
| 388 |
+
maximum=5,
|
| 389 |
+
value = existing_scores.get(desc, 0),
|
| 390 |
+
interactive=True,
|
| 391 |
+
))
|
| 392 |
else:
|
| 393 |
+
slider_updates.append(gr.update(visible=False))
|
| 394 |
+
# for i in range(MAX_SUB_DIMS):
|
| 395 |
+
# if i < len(dimension['sub_dims']):
|
| 396 |
+
# sub_dim_label = dimension['sub_dims'][i]
|
| 397 |
+
# value = existing_scores.get(sub_dim_label, 0)
|
| 398 |
+
# slider_updates.append(gr.update(visible=True, label=sub_dim_label, value=value))
|
| 399 |
+
# else:
|
| 400 |
+
# slider_updates.append(gr.update(visible=False, value=0))
|
| 401 |
|
| 402 |
prev_btn_update = gr.update(interactive=(d_idx > 0))
|
| 403 |
next_btn_update = gr.update(
|
|
|
|
| 905 |
gr.Markdown("--- \n ### 请为对话中的回应者(非发起者)针对以下特征打分 (0-5分。0-特征无体现;1-机器;3-特征无偏向;5-人类)")
|
| 906 |
|
| 907 |
test_sliders = [gr.Slider(minimum=1, maximum=5, step=1, label=f"Sub-dim {i+1}", visible=False, interactive=True, show_label = True) for i in range(MAX_SUB_DIMS)]
|
| 908 |
+
# print(MAX_SUB_DIMS)
|
| 909 |
+
# # slider_index = 0 # 对应 test_sliders 的索引
|
| 910 |
+
# # done = False
|
| 911 |
+
# for dim in DIMENSIONS_DATA:
|
| 912 |
+
# # dim["sub_dims"] 是一个list 里面装着所有的子维度desc
|
| 913 |
+
# for i, desc in enumerate(dim["sub_dims"]): # 每个desc就是“子维度:解释”这样的一个字符串 而不仅是子维度
|
| 914 |
+
# print(f"Checking: {desc}")
|
| 915 |
+
# print("Matched" if any(keyword in desc for keyword in SPECIAL_KEYWORDS) else "Not matched")
|
| 916 |
+
# subdim_name = desc.split(":")[0].strip()
|
| 917 |
+
|
| 918 |
+
# slider = test_sliders[i]
|
| 919 |
+
# if subdim_name in SPECIAL_KEYWORDS:
|
| 920 |
+
# slider.minimum = 0
|
| 921 |
+
# else:
|
| 922 |
+
# slider.minimum = 1
|
| 923 |
# if any(keyword in desc for keyword in SPECIAL_KEYWORDS):# 所以这里用any做字符串匹配
|
| 924 |
# slider.minimum = 0
|
| 925 |
# else:
|