intersteller2887 commited on
Commit
aaae23b
·
verified ·
1 Parent(s): 5c55d55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -15
app.py CHANGED
@@ -150,16 +150,21 @@ def toggle_education_other(choice):
150
  is_other = (choice == "其他(请注明)")
151
  return gr.update(visible=is_other, interactive=is_other, value="")
152
 
153
- def check_info_complete(age, gender, education, education_other):
154
- if age and gender and education:
155
  if education == "其他(请注明)" and not education_other.strip():
156
  return gr.update(interactive=False)
157
  return gr.update(interactive=True)
158
  return gr.update(interactive=False)
159
 
160
- def show_sample_page_and_init(age, gender, education, education_other, user_data):
161
  final_edu = education_other if education == "其他(请注明)" else education
162
- user_data.update({"age": age, "gender": gender, "education": final_edu})
 
 
 
 
 
163
  first_dim_title = DIMENSION_TITLES[0]
164
 
165
  initial_updates = update_sample_view(first_dim_title)
@@ -421,7 +426,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
421
  gender_input = gr.Radio(["男", "女", "其他"], label="性别")
422
  education_input = gr.Radio(["高中及以下", "本科", "硕士", "博士", "其他(请注明)"], label="学历")
423
  education_other_input = gr.Textbox(label="请填写你的学历", visible=False, interactive=False)
424
- # ai_experience_input = gr.Textbox(["从未使用过", "偶尔接触(如看别人用)", "使用过几次,了解基本功能", "经常使用,有一定操作经验", "非常熟悉,深入使用过多个 AI 工具"], label="对 AI 工具的熟悉程度")
425
  submit_info_btn = gr.Button("提交并开始学习样例", variant="primary", interactive=False)
426
 
427
  with sample_page:
@@ -447,12 +452,12 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
447
  "- 对于每一道题,你都需要对全部 **5 个维度** 进行评估。\n"
448
  "- 在每个维度下,请为出现的每个特征 **从1到5打分。\n"
449
  "- **评分解释如下:**\n"
450
- " - **1 分:极度符合机器特征**,如语气僵硬、表达机械、缺乏自然语流等;\n"
451
- " - **2 分:较为符合机器特征**,部分特征显得不自然或存在明显模式化;\n"
452
- " - **3 分:中立,无明显人类或机器倾向**;\n"
453
- " - **4 分:较为符合人类特征**,表现出自然的语用与语言行为;\n"
454
- " - **5 分:极度符合人类特征**,流畅、真实、有情感色彩。\n"
455
- "- 完成所有维度后,请根据整体印象对回应方的身份做出做出“人类”或“机器人”的 **最终判断**。"
456
  "- 你可以使用“上一维度”和“下一维度”按钮在5个维度间自由切换和修改分数。")
457
  go_to_test_btn = gr.Button("开始测试", variant="primary")
458
 
@@ -507,14 +512,18 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
507
 
508
  start_btn.click(fn=start_challenge, outputs=[welcome_page, info_page])
509
 
510
- for comp in [age_input, gender_input, education_input, education_other_input]:
511
- comp.change(fn=check_info_complete, inputs=[age_input, gender_input, education_input, education_other_input], outputs=submit_info_btn)
 
 
 
 
512
 
513
  education_input.change(fn=toggle_education_other, inputs=education_input, outputs=education_other_input)
514
 
515
  submit_info_btn.click(
516
- fn=show_sample_page_and_init,
517
- inputs=[age_input, gender_input, education_input, education_other_input, user_data_state],
518
  outputs=sample_init_outputs
519
  )
520
 
 
150
  is_other = (choice == "其他(请注明)")
151
  return gr.update(visible=is_other, interactive=is_other, value="")
152
 
153
+ def check_info_complete(age, gender, education, education_other, ai_experience):
154
+ if age and gender and education and ai_experience:
155
  if education == "其他(请注明)" and not education_other.strip():
156
  return gr.update(interactive=False)
157
  return gr.update(interactive=True)
158
  return gr.update(interactive=False)
159
 
160
+ def show_sample_page_and_init(age, gender, education, education_other, ai_experience, user_data):
161
  final_edu = education_other if education == "其他(请注明)" else education
162
+ user_data.update({
163
+ "age": age,
164
+ "gender": gender,
165
+ "education": final_edu,
166
+ "ai_experience": ai_experience
167
+ })
168
  first_dim_title = DIMENSION_TITLES[0]
169
 
170
  initial_updates = update_sample_view(first_dim_title)
 
426
  gender_input = gr.Radio(["男", "女", "其他"], label="性别")
427
  education_input = gr.Radio(["高中及以下", "本科", "硕士", "博士", "其他(请注明)"], label="学历")
428
  education_other_input = gr.Textbox(label="请填写你的学历", visible=False, interactive=False)
429
+ ai_experience_input = gr.Textbox(["从未使用过", "偶尔接触(如看别人用)", "使用过几次,了解基本功能", "经常使用,有一定操作经验", "非常熟悉,深入使用过多个 AI 工具"], label="对 AI 工具的熟悉程度")
430
  submit_info_btn = gr.Button("提交并开始学习样例", variant="primary", interactive=False)
431
 
432
  with sample_page:
 
452
  "- 对于每一道题,你都需要对全部 **5 个维度** 进行评估。\n"
453
  "- 在每个维度下,请为出现的每个特征 **从1到5打分。\n"
454
  "- **评分解释如下:**\n"
455
+ " - **1 分:极度符合机器特征**;\n"
456
+ " - **2 分:较为符合机器特征**;\n"
457
+ " - **3 分:无明显人类或机器倾向或特征无体现**;\n"
458
+ " - **4 分:较为符合人类特征**;\n"
459
+ " - **5 分:极度符合人类特征**。\n"
460
+ "- 完成所有维度后,请根据整体印象对回应方的身份做出做出“人类”或“机器人”的 **最终判断**。\n"
461
  "- 你可以使用“上一维度”和“下一维度”按钮在5个维度间自由切换和修改分数。")
462
  go_to_test_btn = gr.Button("开始测试", variant="primary")
463
 
 
512
 
513
  start_btn.click(fn=start_challenge, outputs=[welcome_page, info_page])
514
 
515
+ for comp in [age_input, gender_input, education_input, education_other_input, ai_experience_input]:
516
+ comp.change(
517
+ fn=check_info_complete,
518
+ inputs=[age_input, gender_input, education_input, education_other_input, ai_experience_input],
519
+ outputs=submit_info_btn
520
+ )
521
 
522
  education_input.change(fn=toggle_education_other, inputs=education_input, outputs=education_other_input)
523
 
524
  submit_info_btn.click(
525
+ fn=show_sample_page_and_init,
526
+ inputs=[age_input, gender_input, education_input, education_other_input, ai_experience_input, user_data_state],
527
  outputs=sample_init_outputs
528
  )
529