Spaces:
Sleeping
Sleeping
Merge branch 'main' into cutor_new_bot_structor
Browse files
app.py
CHANGED
@@ -1169,6 +1169,32 @@ def verify_moderation(text):
|
|
1169 |
|
1170 |
return is_flagged, response_dict
|
1171 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1172 |
def assign_grade(subject_content, structure, diction, spelling_punctuation):
|
1173 |
# 定義等級順序
|
1174 |
grade_order = ["A+", "A", "A-", "B+", "B", "B-"]
|
@@ -1275,49 +1301,92 @@ def get_chinese_paragraph_evaluate_content(thread_id, model, user_content, parag
|
|
1275 |
|
1276 |
return total_content_text, content_table
|
1277 |
|
1278 |
-
|
1279 |
def get_chinese_paragraph_1st_evaluate_content(
|
1280 |
thread_id,
|
1281 |
model,
|
1282 |
chinese_assignment_topic,
|
1283 |
chinese_assignment_introduction,
|
1284 |
chinese_assignment_description,
|
1285 |
-
sys_content,
|
1286 |
paragraph,
|
1287 |
-
user_generate_paragraph_evaluate_prompt
|
1288 |
):
|
1289 |
verify_string_length(paragraph)
|
1290 |
verify_moderation(paragraph)
|
1291 |
verify_string_length_short(paragraph)
|
1292 |
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1300 |
|
1301 |
-
|
1302 |
-
|
1303 |
-
|
1304 |
-
assignment_introduction: {chinese_assignment_introduction}
|
1305 |
-
assignment_description: {chinese_assignment_description}
|
1306 |
-
請根據 assignment_topic, assignment_introduction, assignment_description 來評分
|
1307 |
-
如果 paragraph 的內容與 assignment_topic, assignment_introduction, assignment_description 無關,請給予最低分,並告知原因
|
1308 |
-
---
|
1309 |
-
"""
|
1310 |
-
else:
|
1311 |
-
assignment_prompt = ""
|
1312 |
|
1313 |
user_content = f"""
|
1314 |
-
sys_content: {
|
|
|
|
|
1315 |
---
|
1316 |
-
{assignment_prompt}
|
1317 |
paragraph is: {paragraph}
|
1318 |
---
|
1319 |
-
{
|
1320 |
-
{
|
1321 |
"""
|
1322 |
total_content_text, content_table = get_chinese_paragraph_evaluate_content(thread_id, model, user_content, paragraph)
|
1323 |
|
@@ -1328,42 +1397,87 @@ def get_chinese_paragraph_refine_evaluate_content(
|
|
1328 |
chinese_assignment_topic,
|
1329 |
chinese_assignment_introduction,
|
1330 |
chinese_assignment_description,
|
1331 |
-
sys_content,
|
1332 |
paragraph_2,
|
1333 |
-
user_refine_paragraph_prompt
|
1334 |
):
|
1335 |
verify_string_length(paragraph_2)
|
1336 |
verify_moderation(paragraph_2)
|
1337 |
verify_string_length_short(paragraph_2)
|
1338 |
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1358 |
|
|
|
|
|
|
|
|
|
1359 |
user_content = f"""
|
1360 |
-
sys_content: {
|
1361 |
---
|
1362 |
{assignment_prompt}
|
1363 |
refined paragraph is: {paragraph_2}
|
1364 |
---
|
1365 |
-
{
|
1366 |
-
{
|
1367 |
"""
|
1368 |
total_content_text, content_table = get_chinese_paragraph_evaluate_content(thread_id, model, user_content, paragraph_2)
|
1369 |
|
@@ -3341,70 +3455,6 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3341 |
|
3342 |
# =====中文全文批改=====
|
3343 |
with gr.Tab("中文全文批改") as chinese_full_paragraph_tab:
|
3344 |
-
with gr.Row(visible=False) as chinese_full_paragraph_params:
|
3345 |
-
chinese_full_paragraph_sys_content_input = gr.Textbox(label="System Prompt", value="You are a Chinese teacher who is practicing with me to improve my Chinese writing skill.")
|
3346 |
-
default_user_generate_chinese_full_paragraph_evaluate_prompt = """
|
3347 |
-
# 請嚴格根據 instructions
|
3348 |
-
|
3349 |
-
# Rules:
|
3350 |
-
1. 先檢查是否是合理的作文或是段落,再進行評分
|
3351 |
-
2. 請確保作文或段落的內容完整,並且符合中文語法
|
3352 |
-
3. 如果是一篇亂打的文章請直接給予回饋:「這篇文章內容不完整,無法進行評分。」
|
3353 |
-
4. 如果無法進行評分 評分標準與回饋的內容跟等級,則為 X
|
3354 |
-
5. 評分標準與回饋根據「A+、A、A- 、B+、 B、 B-」等級來評分,最低為 B-
|
3355 |
-
|
3356 |
-
# Restrictions:
|
3357 |
-
1. 不用給整體評分
|
3358 |
-
2. 不用改標點符號
|
3359 |
-
3. 評分標準的分數等級請使用「A+、A、A- 、B+、 B、 B-」等級,不可使用數字或是其他等級,像是「90分、80分、C、D」等等。
|
3360 |
-
|
3361 |
-
# Output format:
|
3362 |
-
1. 先給 綜合回饋、評分標準與回饋、修改範例
|
3363 |
-
2. 再將評分標準與回饋的內容以JSON格式輸出,並且請使用繁體中文(ZH-TW)來評分段落並輸出,用 ```json ..... ``` 包裹:
|
3364 |
-
3. please use Chinese language (ZH-TW) to evaluate the paragraph and output use JSON format:
|
3365 |
-
|
3366 |
-
EXAMPLE:
|
3367 |
-
# 綜合回饋
|
3368 |
-
你的文章...............(寫出一段話,來總結這篇作文的好壞)
|
3369 |
-
|
3370 |
-
# 評分標準與回饋
|
3371 |
-
主題與內容:B+ 你的主題很明確,講述了CSS在渲染空間上的問題及解決方案,這是一個重要而實用的話題。然而,內容相對較少,缺乏足夠的細節與實例來支撐你的觀點。建議你可以添加一些具體情境或例子,讓讀者更容易理解CSS的應用情況,例如提到常見的渲染問題以及具體的解決方法。
|
3372 |
-
|
3373 |
-
段落結構:B 你的段落結構基本清晰,但目前只有一段,這使得整體文章顯得有些單薄。建議你可以將內容分成幾個小段落,每個段落著重於不同的要點,例如一段說明問題,另一段探討解決方案,這樣整體更具條理性。
|
3374 |
-
|
3375 |
-
遣詞造句:A 你的遣詞造句大致良好,用詞得體且通順。不過可以嘗試加一些更具體的技術詞彙或示例,使文章更專業化。
|
3376 |
-
|
3377 |
-
# 修改範例
|
3378 |
-
- 原文:內容雖然簡短,但主題明確。
|
3379 |
-
- 修改:雖然內容相對簡短,但主題表達得非常明確。
|
3380 |
-
- 原文:缺乏實例和具體情境來支持內容。
|
3381 |
-
- 修改:目前缺少具體的實例及情境來支持文章的內容與主張。
|
3382 |
-
- 原文:可以進一步擴展。
|
3383 |
-
- 修改:可以進一步擴展來豐富內容,讓讀者更有共鳴。
|
3384 |
-
|
3385 |
-
```json
|
3386 |
-
{{
|
3387 |
-
"results": {{
|
3388 |
-
"主題與內容": {{
|
3389 |
-
"level": "A+",
|
3390 |
-
"explanation": "#中文解釋 ZH-TW"
|
3391 |
-
}},
|
3392 |
-
"段落結構": {{
|
3393 |
-
"level": "B+",
|
3394 |
-
"explanation": "#中文解釋 ZH-TW"
|
3395 |
-
}},
|
3396 |
-
"遣詞造句": {{
|
3397 |
-
"level": "C",
|
3398 |
-
"explanation": "#中文解釋 ZH-TW"
|
3399 |
-
}}
|
3400 |
-
}}
|
3401 |
-
}}
|
3402 |
-
```
|
3403 |
-
|
3404 |
-
Restrictions:
|
3405 |
-
- ALL the content should be in Traditional Chinese (zh-TW), it's very important.
|
3406 |
-
"""
|
3407 |
-
user_generate_chinese_full_paragraph_evaluate_prompt = gr.Textbox(label="Paragraph evaluate Prompt", value=default_user_generate_chinese_full_paragraph_evaluate_prompt)
|
3408 |
with gr.Row():
|
3409 |
gr.Markdown("# 輸入段落全文")
|
3410 |
with gr.Row():
|
@@ -3421,71 +3471,6 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3421 |
# 修改文章
|
3422 |
with gr.Row():
|
3423 |
gr.Markdown("# 根據建議修改文章")
|
3424 |
-
with gr.Row(visible=False) as chinese_full_paragraph_refine_params:
|
3425 |
-
default_user_generate_chinese_full_paragraph_refine_evaluate_prompt = """
|
3426 |
-
# 請嚴格根據 instructions
|
3427 |
-
# Rules:
|
3428 |
-
1. 我給你兩篇文章,請進行比較跟批改,並給出建議,如果文章完全一樣,請給出回饋:「這兩篇文章內容完全一樣,無法進行評分。」,後續評分給予 level X,仍要輸出 JSON
|
3429 |
-
2. 先檢查是否是合理的作文或是段落,再進行評分
|
3430 |
-
2. 請確保作文或段落的內容完整,並且符合中文語法
|
3431 |
-
3. 如果是一篇亂打的文章請直接給予回饋:「這篇文章內容不完整,無法進行評分。」
|
3432 |
-
4. 如果無法進行評分 評分標準與回饋的內容跟等級,則為 X
|
3433 |
-
5. 針對修改後的評分標準與回饋根據「A+、A、A- 、B+、 B、 B-」等級來評分,最低為 B-
|
3434 |
-
|
3435 |
-
# Restrictions:
|
3436 |
-
1. 不用給整體評分
|
3437 |
-
2. 不用改標點符號
|
3438 |
-
3. 評分標準的分數等級請使用「A+、A、A- 、B+、 B、 B-」等級,不可使用數字或是其他等級,像是「90分、80分、C、D」等等。
|
3439 |
-
4. 回傳的 output json 不需要有原文的評分,只需要有修改後的評分
|
3440 |
-
|
3441 |
-
# Output format:
|
3442 |
-
1. 先給 綜合回饋、評分標準與回饋、修改範例
|
3443 |
-
2. 再將評分標準與回饋的內容以JSON格式輸出,並且請使用繁體中文(ZH-TW)來評分段落並輸出,用 ```json ..... ``` 包裹:
|
3444 |
-
3. please use Chinese language (ZH-TW) to evaluate the paragraph and output use JSON format:
|
3445 |
-
4. if the score is X, please still follow the format and give the key as level and value as 'X'. then give the explanation in Chinese
|
3446 |
-
|
3447 |
-
EXAMPLE:
|
3448 |
-
# 綜合回饋(前後比較)
|
3449 |
-
你的文章...............(寫出一段話,比較兩篇作文的差異)
|
3450 |
-
|
3451 |
-
# 評分標準與回饋
|
3452 |
-
主題與內容:B+ 你的主題很明確,講述了CSS在渲染空間上的問題及解決方案,這是一個重要而實用的話題。然而,內容相對較少,缺乏足夠的細節與實例來支撐你的觀點。建議你可以添加一些具體情境或例子,讓讀者更容易理解CSS的應用情況,例如提到常見的渲染問題以及具體的解決方法。
|
3453 |
-
|
3454 |
-
段落結構:B 你的段落結構基本清晰,但目前只有一段,這使得整體文章顯得有些單薄。建議你可以將內容分成幾個小段落,每個段落著重於不同的要點,例如一段說明問題,另一段探討解決方案,這樣整體更具條理性。
|
3455 |
-
|
3456 |
-
遣詞造句:A 你的遣詞造句大致良好,用詞得體且通順。不過可以嘗試加一些更具體的技術詞彙或示例,使文章更專業化。
|
3457 |
-
|
3458 |
-
# 修改範例
|
3459 |
-
- 原文:內容雖然簡短,但主題明確。
|
3460 |
-
- 修改:雖然內容相對簡短,但主題表達得非常明確。
|
3461 |
-
- 原文:缺乏實例和具體情境來支持內容。
|
3462 |
-
- 修改:目前缺少具體的實例及情境來支持文章的內容與主張。
|
3463 |
-
- 原文:可以進一步擴展。
|
3464 |
-
- 修改:可以進一步擴展來豐富內容,讓讀者更有共鳴。
|
3465 |
-
|
3466 |
-
```json
|
3467 |
-
{{
|
3468 |
-
"results": {{
|
3469 |
-
"主題與內容": {{
|
3470 |
-
"level": "A+",
|
3471 |
-
"explanation": "#中文解釋 ZH-TW"
|
3472 |
-
}},
|
3473 |
-
"段落結構": {{
|
3474 |
-
"level": "B+",
|
3475 |
-
"explanation": "#中文解釋 ZH-TW"
|
3476 |
-
}},
|
3477 |
-
"遣詞造句": {{
|
3478 |
-
"level": "C",
|
3479 |
-
"explanation": "#中文解釋 ZH-TW"
|
3480 |
-
}}
|
3481 |
-
}}
|
3482 |
-
}}
|
3483 |
-
```
|
3484 |
-
|
3485 |
-
Restrictions:
|
3486 |
-
- ALL the content should be in Traditional Chinese (zh-TW), it's very important.
|
3487 |
-
"""
|
3488 |
-
user_generate_chinese_full_paragraph_refine_evaluate_prompt = gr.Textbox(label="Paragraph evaluate Prompt", value=default_user_generate_chinese_full_paragraph_refine_evaluate_prompt)
|
3489 |
with gr.Row():
|
3490 |
with gr.Column():
|
3491 |
chinese_full_paragraph_refine_input = gr.TextArea(label="這是你的原始寫作內容,參考建議,你可以選擇是否修改:", show_copy_button=True)
|
@@ -3569,6 +3554,12 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3569 |
)
|
3570 |
|
3571 |
chinese_full_paragraph_evaluate_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
3572 |
fn=get_chinese_conversation_thread_id,
|
3573 |
inputs=[chinese_thread_id_state],
|
3574 |
outputs=[chinese_thread_id_state]
|
@@ -3580,9 +3571,7 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3580 |
chinese_assignment_topic,
|
3581 |
chinese_assignment_introduction,
|
3582 |
chinese_assignment_description,
|
3583 |
-
chinese_full_paragraph_sys_content_input,
|
3584 |
chinese_full_paragraph_input,
|
3585 |
-
user_generate_chinese_full_paragraph_evaluate_prompt
|
3586 |
],
|
3587 |
outputs=[
|
3588 |
chinese_full_paragraph_evaluate_output_text,
|
@@ -3592,9 +3581,19 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3592 |
fn=duplicate_element,
|
3593 |
inputs=[chinese_full_paragraph_input],
|
3594 |
outputs=chinese_full_paragraph_refine_input
|
|
|
|
|
|
|
|
|
3595 |
)
|
3596 |
|
3597 |
generate_chinese_full_paragraph_refine_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
3598 |
fn=get_chinese_conversation_thread_id,
|
3599 |
inputs=[chinese_thread_id_state],
|
3600 |
outputs=[chinese_thread_id_state]
|
@@ -3606,11 +3605,12 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3606 |
chinese_assignment_topic,
|
3607 |
chinese_assignment_introduction,
|
3608 |
chinese_assignment_description,
|
3609 |
-
|
3610 |
-
chinese_full_paragraph_refine_input,
|
3611 |
-
user_generate_chinese_full_paragraph_refine_evaluate_prompt
|
3612 |
-
],
|
3613 |
outputs=[chinese_full_paragraph_refine_output_text, chinese_full_paragraph_refine_output_table]
|
|
|
|
|
|
|
|
|
3614 |
)
|
3615 |
|
3616 |
chinese_full_paragraph_save_button.click(
|
|
|
1169 |
|
1170 |
return is_flagged, response_dict
|
1171 |
|
1172 |
+
def generate_size_count_prompt(paragraph):
|
1173 |
+
if len(paragraph) > 100 and len(paragraph) < 200:
|
1174 |
+
size_count_prompt = """
|
1175 |
+
# Restrictions:
|
1176 |
+
1. 目前提交字數在100-200字之間,主題與內容的評等最高只能是B+。
|
1177 |
+
2. 請在主題與內容的回饋中加一句:「文章字數一定要超過200字,請閱讀回饋以後充實你的作文內容。」
|
1178 |
+
"""
|
1179 |
+
else:
|
1180 |
+
size_count_prompt = ""
|
1181 |
+
|
1182 |
+
return size_count_prompt
|
1183 |
+
|
1184 |
+
def generate_assignment_prompt(chinese_assignment_topic, chinese_assignment_introduction, chinese_assignment_description):
|
1185 |
+
if chinese_assignment_topic != "":
|
1186 |
+
assignment_prompt = f"""
|
1187 |
+
assignment_topic: {chinese_assignment_topic}
|
1188 |
+
assignment_introduction: {chinese_assignment_introduction}
|
1189 |
+
assignment_description: {chinese_assignment_description}
|
1190 |
+
請根據 assignment_topic, assignment_introduction, assignment_description 來評分
|
1191 |
+
如果 paragraph 的內容與 assignment_topic, assignment_introduction, assignment_description 無關,請給予最低分,並告知原因
|
1192 |
+
"""
|
1193 |
+
else:
|
1194 |
+
assignment_prompt = ""
|
1195 |
+
|
1196 |
+
return assignment_prompt
|
1197 |
+
|
1198 |
def assign_grade(subject_content, structure, diction, spelling_punctuation):
|
1199 |
# 定義等級順序
|
1200 |
grade_order = ["A+", "A", "A-", "B+", "B", "B-"]
|
|
|
1301 |
|
1302 |
return total_content_text, content_table
|
1303 |
|
|
|
1304 |
def get_chinese_paragraph_1st_evaluate_content(
|
1305 |
thread_id,
|
1306 |
model,
|
1307 |
chinese_assignment_topic,
|
1308 |
chinese_assignment_introduction,
|
1309 |
chinese_assignment_description,
|
|
|
1310 |
paragraph,
|
|
|
1311 |
):
|
1312 |
verify_string_length(paragraph)
|
1313 |
verify_moderation(paragraph)
|
1314 |
verify_string_length_short(paragraph)
|
1315 |
|
1316 |
+
size_count_prompt = generate_size_count_prompt(paragraph)
|
1317 |
+
assignment_prompt = generate_assignment_prompt(chinese_assignment_topic, chinese_assignment_introduction, chinese_assignment_description)
|
1318 |
+
sys_content_prompt = "You are a Chinese teacher who is practicing with me to improve my Chinese writing skill."
|
1319 |
+
|
1320 |
+
paragraph_evaluate_prompt = """
|
1321 |
+
# 請嚴格根據 instructions
|
1322 |
+
# Rules:
|
1323 |
+
1. 先檢查是否是合理的作文或是段落,再進行評分
|
1324 |
+
2. 請確保作文或段落的內容完整,並且符合中文語法
|
1325 |
+
3. 如果是一篇亂打的文章請直接給予回饋:「這篇文章內容不完整,無法進行評分。」
|
1326 |
+
4. 如果無法進行評分 評分標準與回饋的內容跟等級,則為 X
|
1327 |
+
5. 評分標準與回饋根據「A+、A、A- 、B+、 B、 B-」等級來評分,最低為 B-
|
1328 |
+
|
1329 |
+
# Restrictions:
|
1330 |
+
1. 不用給整體評分
|
1331 |
+
2. 不用改標點符號
|
1332 |
+
3. 評分標準的分數等級請使用「A+、A、A- 、B+、 B、 B-」等級,不可使用數字或是其他等級,像是「90分、80分、C、D」等等。
|
1333 |
+
|
1334 |
+
# Output format:
|
1335 |
+
1. 先給 綜合回饋、評分標準與回饋、修改範例
|
1336 |
+
2. 再將評分標準與回饋的內容以JSON格式輸出,並且請使用繁體中文(ZH-TW)來評分段落並輸出,用 ```json ..... ``` 包裹:
|
1337 |
+
3. please use Chinese language (ZH-TW) to evaluate the paragraph and output use JSON format:
|
1338 |
+
|
1339 |
+
EXAMPLE:
|
1340 |
+
# 綜合回饋
|
1341 |
+
你的文章...............(寫出一段話,來總結這篇作文的好壞)
|
1342 |
+
|
1343 |
+
# 評分標準與回饋
|
1344 |
+
主題與內容:B+ 你的主題很明確,講述了CSS在渲染空間上的問題及解決方案,這是一個重要而實用的話題。然而,內容相對較少,缺乏足夠的細節與實例來支撐你的觀點。建議你可以添加一些具體情境或例子,讓讀者更容易理解CSS的應用情況,例如提到常見的渲染問題以及具體的解決方法。
|
1345 |
+
|
1346 |
+
段落結構:B 你的段落結構基本清晰,但目前只有一段,這使得整體文章顯得有些單薄。建議你可以將內容分成幾個小段落,每個段落著重於不同的要點,例如一段說明問題,另一段探討解決方案,這樣整體更具條理性。
|
1347 |
+
|
1348 |
+
遣詞造句:A 你的遣詞造句大致良好,用詞得體且通順。不過可以嘗試加一些更具體的技術詞彙或示例,使文章更專業化。
|
1349 |
+
|
1350 |
+
# 修改範例
|
1351 |
+
- 原文:內容雖然簡短,但主題明確。
|
1352 |
+
- 修改:雖然內容相對簡短,但主題表達得非常明確。
|
1353 |
+
- 原文:缺乏實例和具體情境來支持內容。
|
1354 |
+
- 修改:目前缺少具體的實例及情境來支持文章的內容與主張。
|
1355 |
+
- 原文:可以進一步擴展。
|
1356 |
+
- 修改:可以進一步擴展來豐富內容,讓讀者更有共鳴。
|
1357 |
+
|
1358 |
+
```json
|
1359 |
+
{{
|
1360 |
+
"results": {{
|
1361 |
+
"主題與內容": {{
|
1362 |
+
"level": "A+",
|
1363 |
+
"explanation": "#中文解釋 ZH-TW"
|
1364 |
+
}},
|
1365 |
+
"段落結構": {{
|
1366 |
+
"level": "B+",
|
1367 |
+
"explanation": "#中文解釋 ZH-TW"
|
1368 |
+
}},
|
1369 |
+
"遣詞造句": {{
|
1370 |
+
"level": "C",
|
1371 |
+
"explanation": "#中文解釋 ZH-TW"
|
1372 |
+
}}
|
1373 |
+
}}
|
1374 |
+
}}
|
1375 |
+
```
|
1376 |
|
1377 |
+
Restrictions:
|
1378 |
+
- ALL the content should be in Traditional Chinese (zh-TW), it's very important.
|
1379 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1380 |
|
1381 |
user_content = f"""
|
1382 |
+
sys_content: {sys_content_prompt}
|
1383 |
+
---
|
1384 |
+
assignment_prompt: {assignment_prompt}
|
1385 |
---
|
|
|
1386 |
paragraph is: {paragraph}
|
1387 |
---
|
1388 |
+
paragraph_evaluate_prompt: {paragraph_evaluate_prompt}
|
1389 |
+
size_count_prompt: {size_count_prompt}
|
1390 |
"""
|
1391 |
total_content_text, content_table = get_chinese_paragraph_evaluate_content(thread_id, model, user_content, paragraph)
|
1392 |
|
|
|
1397 |
chinese_assignment_topic,
|
1398 |
chinese_assignment_introduction,
|
1399 |
chinese_assignment_description,
|
|
|
1400 |
paragraph_2,
|
|
|
1401 |
):
|
1402 |
verify_string_length(paragraph_2)
|
1403 |
verify_moderation(paragraph_2)
|
1404 |
verify_string_length_short(paragraph_2)
|
1405 |
|
1406 |
+
size_count_prompt = generate_size_count_prompt(paragraph_2)
|
1407 |
+
assignment_prompt = generate_assignment_prompt(chinese_assignment_topic, chinese_assignment_introduction, chinese_assignment_description)
|
1408 |
+
sys_content_prompt = "You are a Chinese teacher who is practicing with me to improve my Chinese writing skill."
|
1409 |
+
paragraph_evaluate_prompt = f"""
|
1410 |
+
# 請嚴格根據 instructions
|
1411 |
+
# Rules:
|
1412 |
+
1. 我給你兩篇文章,請進行比較跟批改,並給出建議,如果文章完全一樣,請給出回饋:「這兩篇文章內容完全一樣,無法進行評分。」,後續評分給予 level X,仍要輸出 JSON
|
1413 |
+
2. 先檢查是否是合理的作文或是段落,再進行評分
|
1414 |
+
2. 請確保作文或段落的內容完整,並且符合中文語法
|
1415 |
+
3. 如果是一篇亂打的文章請直接給予回饋:「這篇文章內容不完整,無法進行評分。」
|
1416 |
+
4. 如果無法進行評分 評分標準與回饋的內容跟等級,則為 X
|
1417 |
+
5. 針對修改後的評分標準與回饋根據「A+、A、A- 、B+、 B、 B-」等級來評分,最低為 B-
|
1418 |
+
|
1419 |
+
# Restrictions:
|
1420 |
+
1. 不用給整體評分
|
1421 |
+
2. 不用改標點符號
|
1422 |
+
3. 評分標準的分數等級請使用「A+、A、A- 、B+、 B、 B-」等級,不可使用數字或是其他等級,像是「90分、80分、C、D」等等。
|
1423 |
+
4. 回傳的 output json 不需要有原文的評分,只���要有修改後的評分
|
1424 |
+
|
1425 |
+
# Output format:
|
1426 |
+
1. 先給 綜合回饋、評分標準與回饋、修改範例
|
1427 |
+
2. 再將評分標準與回饋的內容以JSON格式輸出,並且請使用繁體中文(ZH-TW)來評分段落並輸出,用 ```json ..... ``` 包裹:
|
1428 |
+
3. please use Chinese language (ZH-TW) to evaluate the paragraph and output use JSON format:
|
1429 |
+
4. if the score is X, please still follow the format and give the key as level and value as 'X'. then give the explanation in Chinese
|
1430 |
+
|
1431 |
+
EXAMPLE:
|
1432 |
+
# 綜合回饋(前後比較)
|
1433 |
+
你的文章...............(寫出一段話,比較兩篇作文的差異)
|
1434 |
+
|
1435 |
+
# 評分標準與回饋
|
1436 |
+
主題與內容:B+ 你的主題很明確,講述了CSS在渲染空間上的問題及解決方案,這是一個重要而實用的話題。然而,內容相對較少,缺乏足夠的細節與實例來支撐你的觀點。建議你可以添加一些具體情境或例子,讓讀者更容易理解CSS的應用情況,例如提到常見的渲染問題以及具體的解決方法。
|
1437 |
+
|
1438 |
+
段落結構:B 你的段落結構基本清晰,但目前只有一段,這使得整體文章顯得有些單薄。建議你可以將內容分成幾個小段落,每個段落著重於不同的要點,例如一段說明問題,另一段探討解決方案,這樣整體更具條理性。
|
1439 |
+
|
1440 |
+
遣詞造句:A 你的遣詞造句大致良好,用詞得體且通順。不過可以嘗試加一些更具體的技術詞彙或示例,使文章更專業化。
|
1441 |
+
|
1442 |
+
# 修改範例
|
1443 |
+
- 原文:內容雖然簡短,但主題明確。
|
1444 |
+
- 修改:雖然內容相對簡短,但主題表達得非常明確。
|
1445 |
+
- 原文:缺乏實例和具體情境來支持內容。
|
1446 |
+
- 修改:目前缺少具體的實例及情境來支持文章的內容與主張。
|
1447 |
+
- 原文:可以進一步擴展。
|
1448 |
+
- 修改:可以進一步擴展來豐富內容,讓讀者更有共鳴。
|
1449 |
+
|
1450 |
+
```json
|
1451 |
+
{{
|
1452 |
+
"results": {{
|
1453 |
+
"主題與內容": {{
|
1454 |
+
"level": "A+",
|
1455 |
+
"explanation": "#中文解釋 ZH-TW"
|
1456 |
+
}},
|
1457 |
+
"段落結構": {{
|
1458 |
+
"level": "B+",
|
1459 |
+
"explanation": "#中文解釋 ZH-TW"
|
1460 |
+
}},
|
1461 |
+
"遣詞造句": {{
|
1462 |
+
"level": "C",
|
1463 |
+
"explanation": "#中文解釋 ZH-TW"
|
1464 |
+
}}
|
1465 |
+
}}
|
1466 |
+
}}
|
1467 |
+
```
|
1468 |
|
1469 |
+
Restrictions:
|
1470 |
+
- ALL the content should be in Traditional Chinese (zh-TW), it's very important.
|
1471 |
+
"""
|
1472 |
+
|
1473 |
user_content = f"""
|
1474 |
+
sys_content: {sys_content_prompt}
|
1475 |
---
|
1476 |
{assignment_prompt}
|
1477 |
refined paragraph is: {paragraph_2}
|
1478 |
---
|
1479 |
+
paragraph_evaluate_prompt: {paragraph_evaluate_prompt}
|
1480 |
+
size_count_prompt: {size_count_prompt}
|
1481 |
"""
|
1482 |
total_content_text, content_table = get_chinese_paragraph_evaluate_content(thread_id, model, user_content, paragraph_2)
|
1483 |
|
|
|
3455 |
|
3456 |
# =====中文全文批改=====
|
3457 |
with gr.Tab("中文全文批改") as chinese_full_paragraph_tab:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3458 |
with gr.Row():
|
3459 |
gr.Markdown("# 輸入段落全文")
|
3460 |
with gr.Row():
|
|
|
3471 |
# 修改文章
|
3472 |
with gr.Row():
|
3473 |
gr.Markdown("# 根據建議修改文章")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3474 |
with gr.Row():
|
3475 |
with gr.Column():
|
3476 |
chinese_full_paragraph_refine_input = gr.TextArea(label="這是你的原始寫作內容,參考建議,你可以選擇是否修改:", show_copy_button=True)
|
|
|
3554 |
)
|
3555 |
|
3556 |
chinese_full_paragraph_evaluate_button.click(
|
3557 |
+
fn=disable_elements,
|
3558 |
+
inputs=[],
|
3559 |
+
outputs=[
|
3560 |
+
chinese_full_paragraph_evaluate_button
|
3561 |
+
]
|
3562 |
+
).then(
|
3563 |
fn=get_chinese_conversation_thread_id,
|
3564 |
inputs=[chinese_thread_id_state],
|
3565 |
outputs=[chinese_thread_id_state]
|
|
|
3571 |
chinese_assignment_topic,
|
3572 |
chinese_assignment_introduction,
|
3573 |
chinese_assignment_description,
|
|
|
3574 |
chinese_full_paragraph_input,
|
|
|
3575 |
],
|
3576 |
outputs=[
|
3577 |
chinese_full_paragraph_evaluate_output_text,
|
|
|
3581 |
fn=duplicate_element,
|
3582 |
inputs=[chinese_full_paragraph_input],
|
3583 |
outputs=chinese_full_paragraph_refine_input
|
3584 |
+
).then(
|
3585 |
+
fn=enable_elements,
|
3586 |
+
inputs=[],
|
3587 |
+
outputs=[chinese_full_paragraph_evaluate_button]
|
3588 |
)
|
3589 |
|
3590 |
generate_chinese_full_paragraph_refine_button.click(
|
3591 |
+
fn=disable_elements,
|
3592 |
+
inputs=[],
|
3593 |
+
outputs=[
|
3594 |
+
generate_chinese_full_paragraph_refine_button
|
3595 |
+
]
|
3596 |
+
).then(
|
3597 |
fn=get_chinese_conversation_thread_id,
|
3598 |
inputs=[chinese_thread_id_state],
|
3599 |
outputs=[chinese_thread_id_state]
|
|
|
3605 |
chinese_assignment_topic,
|
3606 |
chinese_assignment_introduction,
|
3607 |
chinese_assignment_description,
|
3608 |
+
chinese_full_paragraph_refine_input, ],
|
|
|
|
|
|
|
3609 |
outputs=[chinese_full_paragraph_refine_output_text, chinese_full_paragraph_refine_output_table]
|
3610 |
+
).then(
|
3611 |
+
fn=enable_elements,
|
3612 |
+
inputs=[],
|
3613 |
+
outputs=[generate_chinese_full_paragraph_refine_button]
|
3614 |
)
|
3615 |
|
3616 |
chinese_full_paragraph_save_button.click(
|