youngtsai commited on
Commit
548eaf3
·
1 Parent(s): bd8cb58

assignment_prompt

Browse files
Files changed (1) hide show
  1. app.py +69 -5
app.py CHANGED
@@ -1273,7 +1273,16 @@ def get_chinese_paragraph_evaluate_content(thread_id, model, user_content, parag
1273
  return total_content_text, content_table
1274
 
1275
 
1276
- def get_chinese_paragraph_1st_evaluate_content(thread_id, model, sys_content, paragraph, user_generate_paragraph_evaluate_prompt):
 
 
 
 
 
 
 
 
 
1277
  verify_string_length(paragraph)
1278
  verify_moderation(paragraph)
1279
  verify_string_length_short(paragraph)
@@ -1286,9 +1295,22 @@ def get_chinese_paragraph_1st_evaluate_content(thread_id, model, sys_content, pa
1286
  else:
1287
  prompt_add = ""
1288
 
 
 
 
 
 
 
 
 
 
 
 
 
1289
  user_content = f"""
1290
  sys_content: {sys_content}
1291
  ---
 
1292
  paragraph is: {paragraph}
1293
  ---
1294
  {user_generate_paragraph_evaluate_prompt}
@@ -1298,7 +1320,15 @@ def get_chinese_paragraph_1st_evaluate_content(thread_id, model, sys_content, pa
1298
 
1299
  return total_content_text, content_table
1300
 
1301
- def get_chinese_paragraph_refine_evaluate_content(thread_id, model, sys_content, paragraph_2, user_refine_paragraph_prompt):
 
 
 
 
 
 
 
 
1302
  verify_string_length(paragraph_2)
1303
  verify_moderation(paragraph_2)
1304
  verify_string_length_short(paragraph_2)
@@ -1311,9 +1341,22 @@ def get_chinese_paragraph_refine_evaluate_content(thread_id, model, sys_content,
1311
  else:
1312
  prompt_add = ""
1313
 
 
 
 
 
 
 
 
 
 
 
 
 
1314
  user_content = f"""
1315
  sys_content: {sys_content}
1316
  ---
 
1317
  refined paragraph is: {paragraph_2}
1318
  ---
1319
  {user_refine_paragraph_prompt}
@@ -3486,8 +3529,20 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
3486
  outputs=[chinese_thread_id_state]
3487
  ).then(
3488
  fn=get_chinese_paragraph_1st_evaluate_content,
3489
- inputs=[chinese_thread_id_state, model, chinese_full_paragraph_sys_content_input, chinese_full_paragraph_input, user_generate_chinese_full_paragraph_evaluate_prompt],
3490
- outputs=[chinese_full_paragraph_evaluate_output_text, chinese_full_paragraph_evaluate_output_table]
 
 
 
 
 
 
 
 
 
 
 
 
3491
  ).then(
3492
  fn=duplicate_element,
3493
  inputs=[chinese_full_paragraph_input],
@@ -3500,7 +3555,16 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
3500
  outputs=[chinese_thread_id_state]
3501
  ).then(
3502
  fn=get_chinese_paragraph_refine_evaluate_content,
3503
- inputs=[chinese_thread_id_state, model, chinese_full_paragraph_sys_content_input, chinese_full_paragraph_refine_input, user_generate_chinese_full_paragraph_refine_evaluate_prompt],
 
 
 
 
 
 
 
 
 
3504
  outputs=[chinese_full_paragraph_refine_output_text, chinese_full_paragraph_refine_output_table]
3505
  )
3506
 
 
1273
  return total_content_text, content_table
1274
 
1275
 
1276
+ def get_chinese_paragraph_1st_evaluate_content(
1277
+ thread_id,
1278
+ model,
1279
+ chinese_assignment_topic,
1280
+ chinese_assignment_introduction,
1281
+ chinese_assignment_description,
1282
+ sys_content,
1283
+ paragraph,
1284
+ user_generate_paragraph_evaluate_prompt
1285
+ ):
1286
  verify_string_length(paragraph)
1287
  verify_moderation(paragraph)
1288
  verify_string_length_short(paragraph)
 
1295
  else:
1296
  prompt_add = ""
1297
 
1298
+ if chinese_assignment_topic != "":
1299
+ assignment_prompt = f"""
1300
+ assignment_topic: {chinese_assignment_topic}
1301
+ assignment_introduction: {chinese_assignment_introduction}
1302
+ assignment_description: {chinese_assignment_description}
1303
+ 請根據 assignment_topic, assignment_introduction, assignment_description 來評分
1304
+ 如果 paragraph 的內容與 assignment_topic, assignment_introduction, assignment_description 無關,請給予最低分,並告知原因
1305
+ ---
1306
+ """
1307
+ else:
1308
+ assignment_prompt = ""
1309
+
1310
  user_content = f"""
1311
  sys_content: {sys_content}
1312
  ---
1313
+ {assignment_prompt}
1314
  paragraph is: {paragraph}
1315
  ---
1316
  {user_generate_paragraph_evaluate_prompt}
 
1320
 
1321
  return total_content_text, content_table
1322
 
1323
+ def get_chinese_paragraph_refine_evaluate_content(
1324
+ thread_id, model,
1325
+ chinese_assignment_topic,
1326
+ chinese_assignment_introduction,
1327
+ chinese_assignment_description,
1328
+ sys_content,
1329
+ paragraph_2,
1330
+ user_refine_paragraph_prompt
1331
+ ):
1332
  verify_string_length(paragraph_2)
1333
  verify_moderation(paragraph_2)
1334
  verify_string_length_short(paragraph_2)
 
1341
  else:
1342
  prompt_add = ""
1343
 
1344
+ if chinese_assignment_topic != "":
1345
+ assignment_prompt = f"""
1346
+ assignment_topic: {chinese_assignment_topic}
1347
+ assignment_introduction: {chinese_assignment_introduction}
1348
+ assignment_description: {chinese_assignment_description}
1349
+ 請根據 assignment_topic, assignment_introduction, assignment_description 來評分
1350
+ 如果 paragraph 的內容與 assignment_topic, assignment_introduction, assignment_description 無關,請給予最低分,並告知原因
1351
+ ---
1352
+ """
1353
+ else:
1354
+ assignment_prompt = ""
1355
+
1356
  user_content = f"""
1357
  sys_content: {sys_content}
1358
  ---
1359
+ {assignment_prompt}
1360
  refined paragraph is: {paragraph_2}
1361
  ---
1362
  {user_refine_paragraph_prompt}
 
3529
  outputs=[chinese_thread_id_state]
3530
  ).then(
3531
  fn=get_chinese_paragraph_1st_evaluate_content,
3532
+ inputs=[
3533
+ chinese_thread_id_state,
3534
+ model,
3535
+ chinese_assignment_topic,
3536
+ chinese_assignment_introduction,
3537
+ chinese_assignment_description,
3538
+ chinese_full_paragraph_sys_content_input,
3539
+ chinese_full_paragraph_input,
3540
+ user_generate_chinese_full_paragraph_evaluate_prompt
3541
+ ],
3542
+ outputs=[
3543
+ chinese_full_paragraph_evaluate_output_text,
3544
+ chinese_full_paragraph_evaluate_output_table
3545
+ ]
3546
  ).then(
3547
  fn=duplicate_element,
3548
  inputs=[chinese_full_paragraph_input],
 
3555
  outputs=[chinese_thread_id_state]
3556
  ).then(
3557
  fn=get_chinese_paragraph_refine_evaluate_content,
3558
+ inputs=[
3559
+ chinese_thread_id_state,
3560
+ model,
3561
+ chinese_assignment_topic,
3562
+ chinese_assignment_introduction,
3563
+ chinese_assignment_description,
3564
+ chinese_full_paragraph_sys_content_input,
3565
+ chinese_full_paragraph_refine_input,
3566
+ user_generate_chinese_full_paragraph_refine_evaluate_prompt
3567
+ ],
3568
  outputs=[chinese_full_paragraph_refine_output_text, chinese_full_paragraph_refine_output_table]
3569
  )
3570