youngtsai commited on
Commit
2685d2a
·
1 Parent(s): 7dbd265

setup_content_buttons(content_buttons_config)

Browse files
Files changed (1) hide show
  1. app.py +360 -158
app.py CHANGED
@@ -3059,170 +3059,372 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
3059
  # inputs=[video_id],
3060
  # outputs=[reading_passage_text]
3061
  # )
3062
- reading_passage_get_button.click(
3063
- get_LLM_content,
3064
- inputs=[video_id, reading_passage_kind],
3065
- outputs=[reading_passage_text]
3066
- )
3067
- reading_passage_create_button.click(
3068
- create_LLM_content,
3069
- inputs=[video_id, df_string_output, reading_passage_kind],
3070
- outputs=[reading_passage_text]
3071
- )
3072
- reading_passage_delete_button.click(
3073
- delete_LLM_content,
3074
- inputs=[video_id, reading_passage_kind],
3075
- outputs=[reading_passage_text]
3076
- )
3077
- reading_passage_edit_button.click(
3078
- enable_edit_mode,
3079
- inputs=[],
3080
- outputs=[reading_passage_text]
3081
- )
3082
- reading_passage_update_button.click(
3083
- update_LLM_content,
3084
- inputs=[video_id, reading_passage_text, reading_passage_kind],
3085
- outputs=[reading_passage_text]
3086
- )
3087
 
3088
- # summary event
3089
- # summary_to_markdown.click(
3090
- # summary_add_markdown_version,
3091
- # inputs=[video_id],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3092
  # outputs=[summary_text]
3093
  # )
3094
- summary_get_button.click(
3095
- get_LLM_content,
3096
- inputs=[video_id, summary_kind],
3097
- outputs=[summary_text]
3098
- )
3099
- summary_create_button.click(
3100
- create_LLM_content,
3101
- inputs=[video_id, df_string_output, summary_kind],
3102
- outputs=[summary_text]
3103
- )
3104
- summary_delete_button.click(
3105
- delete_LLM_content,
3106
- inputs=[video_id, summary_kind],
3107
- outputs=[summary_text]
3108
- )
3109
- summary_edit_button.click(
3110
- enable_edit_mode,
3111
- inputs=[],
3112
- outputs=[summary_text]
3113
- )
3114
- summary_update_button.click(
3115
- update_LLM_content,
3116
- inputs=[video_id, summary_text, summary_kind],
3117
- outputs=[summary_text]
3118
- )
3119
 
3120
- # transcript event
3121
- transcript_get_button.click(
3122
- get_LLM_content,
3123
- inputs=[video_id, transcript_kind],
3124
- outputs=[df_string_output]
3125
- )
3126
- transcript_create_button.click(
3127
- create_LLM_content,
3128
- inputs=[video_id, df_string_output, transcript_kind],
3129
- outputs=[df_string_output]
3130
- )
3131
- transcript_delete_button.click(
3132
- delete_LLM_content,
3133
- inputs=[video_id, transcript_kind],
3134
- outputs=[df_string_output]
3135
- )
3136
- transcript_edit_button.click(
3137
- enable_edit_mode,
3138
- inputs=[],
3139
- outputs=[df_string_output]
3140
- )
3141
- transcript_update_button.click(
3142
- update_LLM_content,
3143
- inputs=[video_id, df_string_output, transcript_kind],
3144
- outputs=[df_string_output]
3145
- )
3146
 
3147
- # key_moments event
3148
- key_moments_get_button.click(
3149
- get_LLM_content,
3150
- inputs=[video_id, key_moments_kind],
3151
- outputs=[key_moments]
3152
- )
3153
- key_moments_create_button.click(
3154
- create_LLM_content,
3155
- inputs=[video_id, df_string_output, key_moments_kind],
3156
- outputs=[key_moments]
3157
- )
3158
- key_moments_delete_button.click(
3159
- delete_LLM_content,
3160
- inputs=[video_id, key_moments_kind],
3161
- outputs=[key_moments]
3162
- )
3163
- key_moments_edit_button.click(
3164
- enable_edit_mode,
3165
- inputs=[],
3166
- outputs=[key_moments]
3167
- )
3168
- key_moments_update_button.click(
3169
- update_LLM_content,
3170
- inputs=[video_id, key_moments, key_moments_kind],
3171
- outputs=[key_moments]
3172
- )
3173
 
3174
- # question_list event
3175
- questions_get_button.click(
3176
- get_LLM_content,
3177
- inputs=[video_id, questions_kind],
3178
- outputs=[questions_json]
3179
- )
3180
- questions_create_button.click(
3181
- create_LLM_content,
3182
- inputs=[video_id, df_string_output, questions_kind],
3183
- outputs=[questions_json]
3184
- )
3185
- questions_delete_button.click(
3186
- delete_LLM_content,
3187
- inputs=[video_id, questions_kind],
3188
- outputs=[questions_json]
3189
- )
3190
- questions_edit_button.click(
3191
- enable_edit_mode,
3192
- inputs=[],
3193
- outputs=[questions_json]
3194
- )
3195
- questions_update_button.click(
3196
- update_LLM_content,
3197
- inputs=[video_id, questions_json, questions_kind],
3198
- outputs=[questions_json]
3199
- )
3200
- # questions_answers event
3201
- questions_answers_get_button.click(
3202
- get_LLM_content,
3203
- inputs=[video_id, questions_answers_kind],
3204
- outputs=[questions_answers_json]
3205
- )
3206
- questions_answers_create_button.click(
3207
- create_LLM_content,
3208
- inputs=[video_id, df_string_output, questions_answers_kind],
3209
- outputs=[questions_answers_json]
3210
- )
3211
- questions_answers_delete_button.click(
3212
- delete_LLM_content,
3213
- inputs=[video_id, questions_answers_kind],
3214
- outputs=[questions_answers_json]
3215
- )
3216
- questions_answers_edit_button.click(
3217
- enable_edit_mode,
3218
- inputs=[],
3219
- outputs=[questions_answers_json]
3220
- )
3221
- questions_answers_update_button.click(
3222
- update_LLM_content,
3223
- inputs=[video_id, questions_answers_json, questions_answers_kind],
3224
- outputs=[questions_answers_json]
3225
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3226
 
3227
 
3228
  # 教師版
 
3059
  # inputs=[video_id],
3060
  # outputs=[reading_passage_text]
3061
  # )
3062
+ # reading_passage_get_button.click(
3063
+ # get_LLM_content,
3064
+ # inputs=[video_id, reading_passage_kind],
3065
+ # outputs=[reading_passage_text]
3066
+ # )
3067
+ # reading_passage_create_button.click(
3068
+ # create_LLM_content,
3069
+ # inputs=[video_id, df_string_output, reading_passage_kind],
3070
+ # outputs=[reading_passage_text]
3071
+ # )
3072
+ # reading_passage_delete_button.click(
3073
+ # delete_LLM_content,
3074
+ # inputs=[video_id, reading_passage_kind],
3075
+ # outputs=[reading_passage_text]
3076
+ # )
3077
+ # reading_passage_edit_button.click(
3078
+ # enable_edit_mode,
3079
+ # inputs=[],
3080
+ # outputs=[reading_passage_text]
3081
+ # )
3082
+ # reading_passage_update_button.click(
3083
+ # update_LLM_content,
3084
+ # inputs=[video_id, reading_passage_text, reading_passage_kind],
3085
+ # outputs=[reading_passage_text]
3086
+ # )
3087
 
3088
+ # # summary event
3089
+ # # summary_to_markdown.click(
3090
+ # # summary_add_markdown_version,
3091
+ # # inputs=[video_id],
3092
+ # # outputs=[summary_text]
3093
+ # # )
3094
+ # summary_get_button.click(
3095
+ # get_LLM_content,
3096
+ # inputs=[video_id, summary_kind],
3097
+ # outputs=[summary_text]
3098
+ # )
3099
+ # summary_create_button.click(
3100
+ # create_LLM_content,
3101
+ # inputs=[video_id, df_string_output, summary_kind],
3102
+ # outputs=[summary_text]
3103
+ # )
3104
+ # summary_delete_button.click(
3105
+ # delete_LLM_content,
3106
+ # inputs=[video_id, summary_kind],
3107
+ # outputs=[summary_text]
3108
+ # )
3109
+ # summary_edit_button.click(
3110
+ # enable_edit_mode,
3111
+ # inputs=[],
3112
+ # outputs=[summary_text]
3113
+ # )
3114
+ # summary_update_button.click(
3115
+ # update_LLM_content,
3116
+ # inputs=[video_id, summary_text, summary_kind],
3117
  # outputs=[summary_text]
3118
  # )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3119
 
3120
+ # # transcript event
3121
+ # transcript_get_button.click(
3122
+ # get_LLM_content,
3123
+ # inputs=[video_id, transcript_kind],
3124
+ # outputs=[df_string_output]
3125
+ # )
3126
+ # transcript_create_button.click(
3127
+ # create_LLM_content,
3128
+ # inputs=[video_id, df_string_output, transcript_kind],
3129
+ # outputs=[df_string_output]
3130
+ # )
3131
+ # transcript_delete_button.click(
3132
+ # delete_LLM_content,
3133
+ # inputs=[video_id, transcript_kind],
3134
+ # outputs=[df_string_output]
3135
+ # )
3136
+ # transcript_edit_button.click(
3137
+ # enable_edit_mode,
3138
+ # inputs=[],
3139
+ # outputs=[df_string_output]
3140
+ # )
3141
+ # transcript_update_button.click(
3142
+ # update_LLM_content,
3143
+ # inputs=[video_id, df_string_output, transcript_kind],
3144
+ # outputs=[df_string_output]
3145
+ # )
3146
 
3147
+ # # key_moments event
3148
+ # key_moments_get_button.click(
3149
+ # get_LLM_content,
3150
+ # inputs=[video_id, key_moments_kind],
3151
+ # outputs=[key_moments]
3152
+ # )
3153
+ # key_moments_create_button.click(
3154
+ # create_LLM_content,
3155
+ # inputs=[video_id, df_string_output, key_moments_kind],
3156
+ # outputs=[key_moments]
3157
+ # )
3158
+ # key_moments_delete_button.click(
3159
+ # delete_LLM_content,
3160
+ # inputs=[video_id, key_moments_kind],
3161
+ # outputs=[key_moments]
3162
+ # )
3163
+ # key_moments_edit_button.click(
3164
+ # enable_edit_mode,
3165
+ # inputs=[],
3166
+ # outputs=[key_moments]
3167
+ # )
3168
+ # key_moments_update_button.click(
3169
+ # update_LLM_content,
3170
+ # inputs=[video_id, key_moments, key_moments_kind],
3171
+ # outputs=[key_moments]
3172
+ # )
3173
 
3174
+ # # question_list event
3175
+ # questions_get_button.click(
3176
+ # get_LLM_content,
3177
+ # inputs=[video_id, questions_kind],
3178
+ # outputs=[questions_json]
3179
+ # )
3180
+ # questions_create_button.click(
3181
+ # create_LLM_content,
3182
+ # inputs=[video_id, df_string_output, questions_kind],
3183
+ # outputs=[questions_json]
3184
+ # )
3185
+ # questions_delete_button.click(
3186
+ # delete_LLM_content,
3187
+ # inputs=[video_id, questions_kind],
3188
+ # outputs=[questions_json]
3189
+ # )
3190
+ # questions_edit_button.click(
3191
+ # enable_edit_mode,
3192
+ # inputs=[],
3193
+ # outputs=[questions_json]
3194
+ # )
3195
+ # questions_update_button.click(
3196
+ # update_LLM_content,
3197
+ # inputs=[video_id, questions_json, questions_kind],
3198
+ # outputs=[questions_json]
3199
+ # )
3200
+ # # questions_answers event
3201
+ # questions_answers_get_button.click(
3202
+ # get_LLM_content,
3203
+ # inputs=[video_id, questions_answers_kind],
3204
+ # outputs=[questions_answers_json]
3205
+ # )
3206
+ # questions_answers_create_button.click(
3207
+ # create_LLM_content,
3208
+ # inputs=[video_id, df_string_output, questions_answers_kind],
3209
+ # outputs=[questions_answers_json]
3210
+ # )
3211
+ # questions_answers_delete_button.click(
3212
+ # delete_LLM_content,
3213
+ # inputs=[video_id, questions_answers_kind],
3214
+ # outputs=[questions_answers_json]
3215
+ # )
3216
+ # questions_answers_edit_button.click(
3217
+ # enable_edit_mode,
3218
+ # inputs=[],
3219
+ # outputs=[questions_answers_json]
3220
+ # )
3221
+ # questions_answers_update_button.click(
3222
+ # update_LLM_content,
3223
+ # inputs=[video_id, questions_answers_json, questions_answers_kind],
3224
+ # outputs=[questions_answers_json]
3225
+ # )
3226
+
3227
+ def setup_content_buttons(buttons_config):
3228
+ for config in buttons_config:
3229
+ button = config['button']
3230
+ action = config['action']
3231
+ inputs = config['inputs']
3232
+ outputs = config['outputs']
3233
+ button.click(
3234
+ action,
3235
+ inputs=inputs,
3236
+ outputs=outputs
3237
+ )
3238
+
3239
+ content_buttons_config = [
3240
+ # Transcript actions
3241
+ {
3242
+ 'button': transcript_get_button,
3243
+ 'action': get_LLM_content,
3244
+ 'inputs': [video_id, transcript_kind],
3245
+ 'outputs': [df_string_output]
3246
+ },
3247
+ {
3248
+ 'button': transcript_create_button,
3249
+ 'action': create_LLM_content,
3250
+ 'inputs': [video_id, df_string_output, transcript_kind],
3251
+ 'outputs': [df_string_output]
3252
+ },
3253
+ {
3254
+ 'button': transcript_delete_button,
3255
+ 'action': delete_LLM_content,
3256
+ 'inputs': [video_id, transcript_kind],
3257
+ 'outputs': [df_string_output]
3258
+ },
3259
+ {
3260
+ 'button': transcript_edit_button,
3261
+ 'action': enable_edit_mode,
3262
+ 'inputs': [],
3263
+ 'outputs': [df_string_output]
3264
+ },
3265
+ {
3266
+ 'button': transcript_update_button,
3267
+ 'action': update_LLM_content,
3268
+ 'inputs': [video_id, df_string_output, transcript_kind],
3269
+ 'outputs': [df_string_output]
3270
+ },
3271
+ # Reading passage actions
3272
+ {
3273
+ 'button': reading_passage_get_button,
3274
+ 'action': get_LLM_content,
3275
+ 'inputs': [video_id, reading_passage_kind],
3276
+ 'outputs': [reading_passage_text]
3277
+ },
3278
+ {
3279
+ 'button': reading_passage_create_button,
3280
+ 'action': create_LLM_content,
3281
+ 'inputs': [video_id, df_string_output, reading_passage_kind],
3282
+ 'outputs': [reading_passage_text]
3283
+ },
3284
+ {
3285
+ 'button': reading_passage_delete_button,
3286
+ 'action': delete_LLM_content,
3287
+ 'inputs': [video_id, reading_passage_kind],
3288
+ 'outputs': [reading_passage_text]
3289
+ },
3290
+ {
3291
+ 'button': reading_passage_edit_button,
3292
+ 'action': enable_edit_mode,
3293
+ 'inputs': [],
3294
+ 'outputs': [reading_passage_text]
3295
+ },
3296
+ {
3297
+ 'button': reading_passage_update_button,
3298
+ 'action': update_LLM_content,
3299
+ 'inputs': [video_id, reading_passage_text, reading_passage_kind],
3300
+ 'outputs': [reading_passage_text]
3301
+ },
3302
+ # Summary actions
3303
+ {
3304
+ 'button': summary_get_button,
3305
+ 'action': get_LLM_content,
3306
+ 'inputs': [video_id, summary_kind],
3307
+ 'outputs': [summary_text]
3308
+ },
3309
+ {
3310
+ 'button': summary_create_button,
3311
+ 'action': create_LLM_content,
3312
+ 'inputs': [video_id, df_string_output, summary_kind],
3313
+ 'outputs': [summary_text]
3314
+ },
3315
+ {
3316
+ 'button': summary_delete_button,
3317
+ 'action': delete_LLM_content,
3318
+ 'inputs': [video_id, summary_kind],
3319
+ 'outputs': [summary_text]
3320
+ },
3321
+ {
3322
+ 'button': summary_edit_button,
3323
+ 'action': enable_edit_mode,
3324
+ 'inputs': [],
3325
+ 'outputs': [summary_text]
3326
+ },
3327
+ {
3328
+ 'button': summary_update_button,
3329
+ 'action': update_LLM_content,
3330
+ 'inputs': [video_id, summary_text, summary_kind],
3331
+ 'outputs': [summary_text]
3332
+ },
3333
+ # Key moments actions
3334
+ {
3335
+ 'button': key_moments_get_button,
3336
+ 'action': get_LLM_content,
3337
+ 'inputs': [video_id, key_moments_kind],
3338
+ 'outputs': [key_moments]
3339
+ },
3340
+ {
3341
+ 'button': key_moments_create_button,
3342
+ 'action': create_LLM_content,
3343
+ 'inputs': [video_id, df_string_output, key_moments_kind],
3344
+ 'outputs': [key_moments]
3345
+ },
3346
+ {
3347
+ 'button': key_moments_delete_button,
3348
+ 'action': delete_LLM_content,
3349
+ 'inputs': [video_id, key_moments_kind],
3350
+ 'outputs': [key_moments]
3351
+ },
3352
+ {
3353
+ 'button': key_moments_edit_button,
3354
+ 'action': enable_edit_mode,
3355
+ 'inputs': [],
3356
+ 'outputs': [key_moments]
3357
+ },
3358
+ {
3359
+ 'button': key_moments_update_button,
3360
+ 'action': update_LLM_content,
3361
+ 'inputs': [video_id, key_moments, key_moments_kind],
3362
+ 'outputs': [key_moments]
3363
+ },
3364
+ # Questions actions
3365
+ {
3366
+ 'button': questions_get_button,
3367
+ 'action': get_LLM_content,
3368
+ 'inputs': [video_id, questions_kind],
3369
+ 'outputs': [questions_json]
3370
+ },
3371
+ {
3372
+ 'button': questions_create_button,
3373
+ 'action': create_LLM_content,
3374
+ 'inputs': [video_id, df_string_output, questions_kind],
3375
+ 'outputs': [questions_json]
3376
+ },
3377
+ {
3378
+ 'button': questions_delete_button,
3379
+ 'action': delete_LLM_content,
3380
+ 'inputs': [video_id, questions_kind],
3381
+ 'outputs': [questions_json]
3382
+ },
3383
+ {
3384
+ 'button': questions_edit_button,
3385
+ 'action': enable_edit_mode,
3386
+ 'inputs': [],
3387
+ 'outputs': [questions_json]
3388
+ },
3389
+ {
3390
+ 'button': questions_update_button,
3391
+ 'action': update_LLM_content,
3392
+ 'inputs': [video_id, questions_json, questions_kind],
3393
+ 'outputs': [questions_json]
3394
+ },
3395
+ # Questions answers actions
3396
+ {
3397
+ 'button': questions_answers_get_button,
3398
+ 'action': get_LLM_content,
3399
+ 'inputs': [video_id, questions_answers_kind],
3400
+ 'outputs': [questions_answers_json]
3401
+ },
3402
+ {
3403
+ 'button': questions_answers_create_button,
3404
+ 'action': create_LLM_content,
3405
+ 'inputs': [video_id, df_string_output, questions_answers_kind],
3406
+ 'outputs': [questions_answers_json]
3407
+ },
3408
+ {
3409
+ 'button': questions_answers_delete_button,
3410
+ 'action': delete_LLM_content,
3411
+ 'inputs': [video_id, questions_answers_kind],
3412
+ 'outputs': [questions_answers_json]
3413
+ },
3414
+ {
3415
+ 'button': questions_answers_edit_button,
3416
+ 'action': enable_edit_mode,
3417
+ 'inputs': [],
3418
+ 'outputs': [questions_answers_json]
3419
+ },
3420
+ {
3421
+ 'button': questions_answers_update_button,
3422
+ 'action': update_LLM_content,
3423
+ 'inputs': [video_id, questions_answers_json, questions_answers_kind],
3424
+ 'outputs': [questions_answers_json]
3425
+ },
3426
+ ]
3427
+ setup_content_buttons(content_buttons_config)
3428
 
3429
 
3430
  # 教師版