Spaces:
Sleeping
Sleeping
with gr.Tab("英文考古題寫作練習"):
Browse files
app.py
CHANGED
@@ -1346,6 +1346,124 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
1346 |
outputs=[full_paragraph_save_output, full_audio_output]
|
1347 |
)
|
1348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1349 |
# =====中文全文批改=====
|
1350 |
with gr.Tab("中文全文批改"):
|
1351 |
with gr.Row(visible=False) as chinese_full_paragraph_params:
|
@@ -1497,121 +1615,5 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
1497 |
outputs=[chinese_full_paragraph_save_output, chinese_full_audio_output]
|
1498 |
)
|
1499 |
|
1500 |
-
|
1501 |
-
with gr.Tab("考古題寫作練習"):
|
1502 |
-
with gr.Row():
|
1503 |
-
with gr.Column():
|
1504 |
-
with gr.Row():
|
1505 |
-
gr.Markdown("# 考古題寫作練習")
|
1506 |
-
with gr.Row():
|
1507 |
-
gr.Markdown("## 選擇考古題")
|
1508 |
-
with gr.Row():
|
1509 |
-
exams_data = load_exam_data()
|
1510 |
-
past_exam_choices = [exam["title"] for exam in exams_data["exams"]]
|
1511 |
-
past_exam_dropdown = gr.Radio(label="選擇考古題", choices=past_exam_choices)
|
1512 |
-
with gr.Row():
|
1513 |
-
past_exam_title = gr.Markdown()
|
1514 |
-
with gr.Row():
|
1515 |
-
with gr.Column():
|
1516 |
-
with gr.Row():
|
1517 |
-
past_exam_question = gr.Markdown()
|
1518 |
-
with gr.Row():
|
1519 |
-
with gr.Accordion("提示", open=False):
|
1520 |
-
with gr.Row():
|
1521 |
-
past_exam_hint = gr.Markdown()
|
1522 |
-
with gr.Column():
|
1523 |
-
past_exam_image = gr.Image()
|
1524 |
-
|
1525 |
-
past_exam_dropdown.select(
|
1526 |
-
fn=update_exam_contents,
|
1527 |
-
inputs=[past_exam_dropdown],
|
1528 |
-
outputs=[past_exam_title, past_exam_question, past_exam_hint, past_exam_image]
|
1529 |
-
)
|
1530 |
-
|
1531 |
-
# 評分
|
1532 |
-
with gr.Row():
|
1533 |
-
with gr.Column():
|
1534 |
-
with gr.Row():
|
1535 |
-
past_exam_evaluation_sys_content_prompt = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.", visible=False)
|
1536 |
-
past_exam_evaluation_user_prompt = gr.Textbox(label="Paragraph evaluate Prompt", value=default_user_generate_paragraph_evaluate_prompt, visible=False)
|
1537 |
-
past_exam_evaluation_input = gr.Textbox("",lines= 10, label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否修改:")
|
1538 |
-
with gr.Column():
|
1539 |
-
with gr.Row():
|
1540 |
-
past_exam_evaluation_button = gr.Button("評分", variant="primary")
|
1541 |
-
with gr.Row():
|
1542 |
-
past_exam_evaluation_output = gr.Dataframe(label="評分結果", wrap=True, column_widths=[20, 15, 65], interactive=False)
|
1543 |
-
|
1544 |
-
# 修正錯字、語法
|
1545 |
-
with gr.Row():
|
1546 |
-
with gr.Column():
|
1547 |
-
past_exam_correct_grammatical_spelling_errors_input = gr.Textbox(label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否修改:",lines= 10, show_copy_button=True)
|
1548 |
-
with gr.Column():
|
1549 |
-
with gr.Row():
|
1550 |
-
with gr.Accordion("prompt 提供微調測試", open=False, elem_classes=['accordion-prompts']):
|
1551 |
-
past_exam_correct_grammatical_spelling_errors_prompt = gr.Textbox(label="Correct Grammatical and Spelling Errors Prompt", value=default_user_correct_grammatical_spelling_errors_prompt, lines= 20)
|
1552 |
-
with gr.Row():
|
1553 |
-
past_exam_generate_correct_grammatical_spelling_errors_button = gr.Button("修訂文法與拼字錯誤", variant="primary")
|
1554 |
-
with gr.Row():
|
1555 |
-
past_exam_correct_grammatical_spelling_errors_output_table = gr.Dataframe(label="修訂文法與拼字錯誤", interactive=False, column_widths=[30, 30, 40])
|
1556 |
-
with gr.Row():
|
1557 |
-
past_exam_revised_output = gr.Textbox(label="Revised Paragraph", show_copy_button=True, visible=False)
|
1558 |
-
with gr.Row():
|
1559 |
-
gr.Markdown("## 修訂結果")
|
1560 |
-
with gr.Row():
|
1561 |
-
past_exam_revised_diff = gr.HTML()
|
1562 |
-
|
1563 |
-
# 修正段落
|
1564 |
-
with gr.Row():
|
1565 |
-
with gr.Column():
|
1566 |
-
past_exam_refine_input = gr.Textbox(label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否修改:", show_copy_button=True,lines= 10)
|
1567 |
-
with gr.Column():
|
1568 |
-
with gr.Row():
|
1569 |
-
with gr.Accordion("prompt 提供微調測試", open=False, elem_classes=['accordion-prompts']):
|
1570 |
-
past_exam_refine_paragraph_prompt = gr.Textbox(label="Refine Paragraph Prompt", value=default_user_refine_paragraph_prompt, lines= 20)
|
1571 |
-
with gr.Row():
|
1572 |
-
past_exam_generate_refine_button = gr.Button("段落改善建議", variant="primary")
|
1573 |
-
with gr.Row():
|
1574 |
-
past_exam_refine_output_table = gr.DataFrame(label="Refine Paragraph 段落改善建議", wrap=True, interactive=False)
|
1575 |
-
with gr.Row():
|
1576 |
-
past_exam_refine_output = gr.HTML(label="修改建議", visible=False)
|
1577 |
-
with gr.Row():
|
1578 |
-
gr.Markdown("## 修改結果")
|
1579 |
-
with gr.Row():
|
1580 |
-
past_exam_refine_output_diff = gr.HTML()
|
1581 |
-
|
1582 |
-
past_exam_evaluation_button.click(
|
1583 |
-
fn=generate_paragraph_evaluate,
|
1584 |
-
inputs=[past_exam_evaluation_sys_content_prompt, past_exam_evaluation_input, past_exam_evaluation_user_prompt],
|
1585 |
-
outputs=past_exam_evaluation_output
|
1586 |
-
).then(
|
1587 |
-
fn=update_paragraph_correct_grammatical_spelling_errors_input,
|
1588 |
-
inputs=[past_exam_evaluation_input],
|
1589 |
-
outputs=past_exam_correct_grammatical_spelling_errors_input
|
1590 |
-
)
|
1591 |
-
|
1592 |
-
past_exam_generate_correct_grammatical_spelling_errors_button.click(
|
1593 |
-
fn=generate_correct_grammatical_spelling_errors,
|
1594 |
-
inputs=[model, past_exam_evaluation_sys_content_prompt, eng_level_input, past_exam_correct_grammatical_spelling_errors_input, past_exam_correct_grammatical_spelling_errors_prompt],
|
1595 |
-
outputs=[past_exam_correct_grammatical_spelling_errors_output_table, past_exam_revised_output]
|
1596 |
-
).then(
|
1597 |
-
fn=highlight_diff_texts,
|
1598 |
-
inputs=[past_exam_correct_grammatical_spelling_errors_output_table, past_exam_revised_output],
|
1599 |
-
outputs=past_exam_revised_diff
|
1600 |
-
).then(
|
1601 |
-
fn=update_paragraph_refine_input,
|
1602 |
-
inputs=[past_exam_correct_grammatical_spelling_errors_input],
|
1603 |
-
outputs=past_exam_refine_input
|
1604 |
-
)
|
1605 |
-
|
1606 |
-
past_exam_generate_refine_button.click(
|
1607 |
-
fn=generate_refine_paragraph,
|
1608 |
-
inputs=[past_exam_evaluation_sys_content_prompt, eng_level_input, past_exam_refine_input, past_exam_refine_paragraph_prompt],
|
1609 |
-
outputs=[past_exam_refine_output_table, past_exam_refine_output]
|
1610 |
-
).then(
|
1611 |
-
fn=highlight_diff_texts,
|
1612 |
-
inputs=[past_exam_refine_output_table, past_exam_refine_output],
|
1613 |
-
outputs=past_exam_refine_output_diff
|
1614 |
-
)
|
1615 |
-
|
1616 |
-
|
1617 |
demo.launch()
|
|
|
1346 |
outputs=[full_paragraph_save_output, full_audio_output]
|
1347 |
)
|
1348 |
|
1349 |
+
# ====="考古題寫作練習"=====
|
1350 |
+
|
1351 |
+
# ====="英文考古題寫作練習====="
|
1352 |
+
with gr.Tab("英文考古題寫作練習"):
|
1353 |
+
with gr.Row():
|
1354 |
+
with gr.Column():
|
1355 |
+
with gr.Row():
|
1356 |
+
gr.Markdown("# 考古題寫作練習")
|
1357 |
+
with gr.Row():
|
1358 |
+
gr.Markdown("## 選擇考古題")
|
1359 |
+
with gr.Row():
|
1360 |
+
exams_data = load_exam_data()
|
1361 |
+
past_exam_choices = [exam["title"] for exam in exams_data["exams"]]
|
1362 |
+
past_exam_dropdown = gr.Radio(label="選擇考古題", choices=past_exam_choices)
|
1363 |
+
with gr.Row():
|
1364 |
+
past_exam_title = gr.Markdown()
|
1365 |
+
with gr.Row():
|
1366 |
+
with gr.Column():
|
1367 |
+
with gr.Row():
|
1368 |
+
past_exam_question = gr.Markdown()
|
1369 |
+
with gr.Row():
|
1370 |
+
with gr.Accordion("提示", open=False):
|
1371 |
+
with gr.Row():
|
1372 |
+
past_exam_hint = gr.Markdown()
|
1373 |
+
with gr.Column():
|
1374 |
+
past_exam_image = gr.Image()
|
1375 |
+
|
1376 |
+
past_exam_dropdown.select(
|
1377 |
+
fn=update_exam_contents,
|
1378 |
+
inputs=[past_exam_dropdown],
|
1379 |
+
outputs=[past_exam_title, past_exam_question, past_exam_hint, past_exam_image]
|
1380 |
+
)
|
1381 |
+
|
1382 |
+
# 評分
|
1383 |
+
with gr.Row():
|
1384 |
+
with gr.Column():
|
1385 |
+
with gr.Row():
|
1386 |
+
past_exam_evaluation_sys_content_prompt = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.", visible=False)
|
1387 |
+
past_exam_evaluation_user_prompt = gr.Textbox(label="Paragraph evaluate Prompt", value=default_user_generate_paragraph_evaluate_prompt, visible=False)
|
1388 |
+
past_exam_evaluation_input = gr.Textbox("",lines= 10, label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否修改:")
|
1389 |
+
with gr.Column():
|
1390 |
+
with gr.Row():
|
1391 |
+
past_exam_evaluation_button = gr.Button("評分", variant="primary")
|
1392 |
+
with gr.Row():
|
1393 |
+
past_exam_evaluation_output = gr.Dataframe(label="評分結果", wrap=True, column_widths=[20, 15, 65], interactive=False)
|
1394 |
+
|
1395 |
+
# 修正錯字、語法
|
1396 |
+
with gr.Row():
|
1397 |
+
with gr.Column():
|
1398 |
+
past_exam_correct_grammatical_spelling_errors_input = gr.Textbox(label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否修改:",lines= 10, show_copy_button=True)
|
1399 |
+
with gr.Column():
|
1400 |
+
with gr.Row():
|
1401 |
+
with gr.Accordion("prompt 提供微調測試", open=False, elem_classes=['accordion-prompts'], visible=False):
|
1402 |
+
past_exam_correct_grammatical_spelling_errors_prompt = gr.Textbox(label="Correct Grammatical and Spelling Errors Prompt", value=default_user_correct_grammatical_spelling_errors_prompt, lines= 20)
|
1403 |
+
with gr.Row():
|
1404 |
+
past_exam_generate_correct_grammatical_spelling_errors_button = gr.Button("修訂文法與拼字錯誤", variant="primary")
|
1405 |
+
with gr.Row():
|
1406 |
+
past_exam_correct_grammatical_spelling_errors_output_table = gr.Dataframe(label="修訂文法與拼字錯誤", interactive=False, column_widths=[30, 30, 40])
|
1407 |
+
with gr.Row():
|
1408 |
+
past_exam_revised_output = gr.Textbox(label="Revised Paragraph", show_copy_button=True, visible=False)
|
1409 |
+
with gr.Row():
|
1410 |
+
gr.Markdown("## 修訂結果")
|
1411 |
+
with gr.Row():
|
1412 |
+
past_exam_revised_diff = gr.HTML()
|
1413 |
+
|
1414 |
+
# 修正段落
|
1415 |
+
with gr.Row():
|
1416 |
+
with gr.Column():
|
1417 |
+
past_exam_refine_input = gr.Textbox(label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否修改:", show_copy_button=True,lines= 10)
|
1418 |
+
with gr.Column():
|
1419 |
+
with gr.Row():
|
1420 |
+
with gr.Accordion("prompt 提供微調測試", open=False, elem_classes=['accordion-prompts'], visible=False):
|
1421 |
+
past_exam_refine_paragraph_prompt = gr.Textbox(label="Refine Paragraph Prompt", value=default_user_refine_paragraph_prompt, lines= 20)
|
1422 |
+
with gr.Row():
|
1423 |
+
past_exam_generate_refine_button = gr.Button("段落改善建議", variant="primary")
|
1424 |
+
with gr.Row():
|
1425 |
+
past_exam_refine_output_table = gr.DataFrame(label="Refine Paragraph 段落改善建議", wrap=True, interactive=False)
|
1426 |
+
with gr.Row():
|
1427 |
+
past_exam_refine_output = gr.HTML(label="修改建議", visible=False)
|
1428 |
+
with gr.Row():
|
1429 |
+
gr.Markdown("## 修改結果")
|
1430 |
+
with gr.Row():
|
1431 |
+
past_exam_refine_output_diff = gr.HTML()
|
1432 |
+
|
1433 |
+
past_exam_evaluation_button.click(
|
1434 |
+
fn=generate_paragraph_evaluate,
|
1435 |
+
inputs=[model, past_exam_evaluation_sys_content_prompt, past_exam_evaluation_input, past_exam_evaluation_user_prompt],
|
1436 |
+
outputs=past_exam_evaluation_output
|
1437 |
+
).then(
|
1438 |
+
fn=update_paragraph_correct_grammatical_spelling_errors_input,
|
1439 |
+
inputs=[past_exam_evaluation_input],
|
1440 |
+
outputs=past_exam_correct_grammatical_spelling_errors_input
|
1441 |
+
)
|
1442 |
+
|
1443 |
+
past_exam_generate_correct_grammatical_spelling_errors_button.click(
|
1444 |
+
fn=generate_correct_grammatical_spelling_errors,
|
1445 |
+
inputs=[model, past_exam_evaluation_sys_content_prompt, eng_level_input, past_exam_correct_grammatical_spelling_errors_input, past_exam_correct_grammatical_spelling_errors_prompt],
|
1446 |
+
outputs=[past_exam_correct_grammatical_spelling_errors_output_table, past_exam_revised_output]
|
1447 |
+
).then(
|
1448 |
+
fn=highlight_diff_texts,
|
1449 |
+
inputs=[past_exam_correct_grammatical_spelling_errors_output_table, past_exam_revised_output],
|
1450 |
+
outputs=past_exam_revised_diff
|
1451 |
+
).then(
|
1452 |
+
fn=update_paragraph_refine_input,
|
1453 |
+
inputs=[past_exam_correct_grammatical_spelling_errors_input],
|
1454 |
+
outputs=past_exam_refine_input
|
1455 |
+
)
|
1456 |
+
|
1457 |
+
past_exam_generate_refine_button.click(
|
1458 |
+
fn=generate_refine_paragraph,
|
1459 |
+
inputs=[model, past_exam_evaluation_sys_content_prompt, eng_level_input, past_exam_refine_input, past_exam_refine_paragraph_prompt],
|
1460 |
+
outputs=[past_exam_refine_output_table, past_exam_refine_output]
|
1461 |
+
).then(
|
1462 |
+
fn=highlight_diff_texts,
|
1463 |
+
inputs=[past_exam_refine_output_table, past_exam_refine_output],
|
1464 |
+
outputs=past_exam_refine_output_diff
|
1465 |
+
)
|
1466 |
+
|
1467 |
# =====中文全文批改=====
|
1468 |
with gr.Tab("中文全文批改"):
|
1469 |
with gr.Row(visible=False) as chinese_full_paragraph_params:
|
|
|
1615 |
outputs=[chinese_full_paragraph_save_output, chinese_full_audio_output]
|
1616 |
)
|
1617 |
|
1618 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1619 |
demo.launch()
|