Spaces:
Sleeping
Sleeping
fn=diff_texts,
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from openai import OpenAI
|
|
|
|
|
|
|
4 |
import json
|
5 |
import tempfile
|
6 |
|
@@ -230,14 +233,29 @@ def generate_paragraph_evaluate(paragraph, user_generate_paragraph_evaluate_prom
|
|
230 |
request_payload = {
|
231 |
"model": "gpt-3.5-turbo",
|
232 |
"messages": messages,
|
233 |
-
"max_tokens":
|
234 |
"response_format": response_format
|
235 |
}
|
236 |
|
237 |
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
238 |
content = response.choices[0].message.content
|
239 |
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
def generate_correct_grammatical_spelling_errors(eng_level, paragraph, user_correct_grammatical_spelling_errors_prompt):
|
243 |
"""
|
@@ -252,21 +270,64 @@ def generate_correct_grammatical_spelling_errors(eng_level, paragraph, user_corr
|
|
252 |
{"role": "system", "content": paragraph},
|
253 |
{"role": "user", "content": user_content}
|
254 |
]
|
255 |
-
|
256 |
response_format = { "type": "json_object" }
|
257 |
-
|
258 |
request_payload = {
|
259 |
"model": "gpt-3.5-turbo",
|
260 |
"messages": messages,
|
261 |
-
"max_tokens":
|
262 |
"response_format": response_format
|
263 |
}
|
264 |
|
265 |
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
266 |
content = response.choices[0].message.content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
267 |
|
268 |
return content
|
269 |
|
|
|
|
|
|
|
270 |
def generate_refine_paragraph(eng_level, paragraph, user_refine_paragraph_prompt):
|
271 |
"""
|
272 |
根据用户输入的段落,调用OpenAI API生成相关的段落改善建议。
|
@@ -295,6 +356,8 @@ def generate_refine_paragraph(eng_level, paragraph, user_refine_paragraph_prompt
|
|
295 |
|
296 |
return content
|
297 |
|
|
|
|
|
298 |
def paragraph_save_and_tts(paragraph_text):
|
299 |
"""
|
300 |
Saves the paragraph text and generates an audio file using OpenAI's TTS.
|
@@ -511,6 +574,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
511 |
Restrictions:
|
512 |
- avoiding overly technical language.
|
513 |
- Total word-count is around 50. no more explanation either no more extra non-relation sentences.
|
|
|
514 |
|
515 |
EXAMPLE:
|
516 |
- Washing your hands often helps you stay healthy. It removes dirt and germs that can make you sick. Clean hands prevent the spread of diseases. You protect yourself and others by washing your hands regularly.
|
@@ -659,11 +723,12 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
659 |
- Fair (2-1 points): Identify if the theme is unclear or if the majority of the narrative is undeveloped or irrelevant to the theme.
|
660 |
- Poor (0 points): Determine if the response is off-topic or not written at all. Remember that any response that is off-topic or unwritten should receive zero points in all aspects.
|
661 |
|
662 |
-
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's content meets the criteria.
|
|
|
663 |
|
664 |
評分結果以 JSON 格式輸出: content: {
|
665 |
-
"
|
666 |
-
"
|
667 |
}
|
668 |
|
669 |
-- 根據上述的文章,以「組織(organization)」層面評分。
|
@@ -677,8 +742,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
677 |
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's Organization meets the criteria. Translate your feedback into Traditional Chinese (zh_tw) as the final result (#中文解釋).
|
678 |
|
679 |
評分結果以 JSON 格式輸出: organization: {
|
680 |
-
"
|
681 |
-
"
|
682 |
}
|
683 |
|
684 |
-- 根據上述的文章,以「文法和用法(Grammar and usage)」層面評分。
|
@@ -692,8 +757,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
692 |
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's Grammar/Sentence Structure meets the criteria. Translate your feedback into Traditional Chinese (zh_tw) as the final result (#中文解釋).
|
693 |
|
694 |
評分結果以 JSON 格式輸出: grammar_and_usage: {
|
695 |
-
"
|
696 |
-
"
|
697 |
}
|
698 |
|
699 |
-- 根據上述的文章,以「詞彙(Vocabulary )」層面評分。
|
@@ -707,18 +772,21 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
707 |
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's Vocabulary/Spelling meets the criteria. Translate your feedback into Traditional Chinese (zh_tw) as the final result (#中文解釋).
|
708 |
|
709 |
評分結果以 JSON 格式輸出: vocabulary: {
|
710 |
-
"
|
711 |
-
"
|
712 |
}
|
713 |
|
714 |
-- 根據上述的文章,以「連貫性和連接詞(Coherence and Cohesion)」層面評分。
|
715 |
- 評分等級有三級:beginner, intermediate, advanced.
|
716 |
- 以繁體中文 zh-TW 解釋
|
717 |
評分結果以 JSON 格式輸出: coherence_and_cohesion: {
|
718 |
-
"
|
719 |
-
"
|
720 |
}
|
721 |
|
|
|
|
|
|
|
722 |
Final Output JSON Format:
|
723 |
{{
|
724 |
“content“: {{content’s dict}},
|
@@ -732,34 +800,77 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
732 |
with gr.Row():
|
733 |
generate_paragraph_evaluate_button = gr.Button("段落分析", variant="primary")
|
734 |
with gr.Row():
|
735 |
-
paragraph_evaluate_output = gr.
|
736 |
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
763 |
|
764 |
gr.Markdown("## 10. Refine Paragraph 段落改善建議")
|
765 |
default_user_refine_paragraph_prompt = """
|
@@ -767,7 +878,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
767 |
- Revised Version 1 (for correction): paragraph_ai_modification(split by punctuation mark)
|
768 |
- Do not modify the sentence: topicSentence"
|
769 |
- Make sure any revised vocabulary aligns with the eng_level.
|
770 |
-
- When explaining, use Traditional Chinese (Taiwan, 繁體中文) for clarity.
|
771 |
- But others(Origin, Suggestion, revised_paragraph_v2) use English, that's very important.
|
772 |
- Guidelines for Length and Complexity:
|
773 |
Please keep explanations concise and straightforward,
|
@@ -775,8 +886,8 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
775 |
The response should strictly be in the below JSON format and nothing else:
|
776 |
{
|
777 |
"Suggestions and Explanations": [
|
778 |
-
{ "Origin": "#original_text_1", "Suggestion": "#suggestion_1", "Explanation": "#explanation_1(in_traditional_chinese)" },
|
779 |
-
{ "Origin": "#original_text_2", "Suggestion": "#suggestion_2", "Explanation": "#explanation_2(in_traditional_chinese)" },
|
780 |
... ],
|
781 |
"Revised Paragraph": "#revised_paragraph_v2"
|
782 |
}
|
@@ -876,15 +987,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
876 |
outputs=paragraph_evaluate_output
|
877 |
)
|
878 |
|
879 |
-
|
880 |
-
fn=generate_correct_grammatical_spelling_errors,
|
881 |
-
inputs=[
|
882 |
-
eng_level_input,
|
883 |
-
paragraph_output,
|
884 |
-
user_correct_grammatical_spelling_errors_prompt
|
885 |
-
],
|
886 |
-
outputs=correct_grammatical_spelling_errors_output
|
887 |
-
)
|
888 |
|
889 |
generate_refine_paragraph_button.click(
|
890 |
fn=generate_refine_paragraph,
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from openai import OpenAI
|
4 |
+
|
5 |
+
from difflib import Differ
|
6 |
+
|
7 |
import json
|
8 |
import tempfile
|
9 |
|
|
|
233 |
request_payload = {
|
234 |
"model": "gpt-3.5-turbo",
|
235 |
"messages": messages,
|
236 |
+
"max_tokens": 2000,
|
237 |
"response_format": response_format
|
238 |
}
|
239 |
|
240 |
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
241 |
content = response.choices[0].message.content
|
242 |
|
243 |
+
print(f"====generate_paragraph_evaluate====")
|
244 |
+
print(content)
|
245 |
+
|
246 |
+
data = json.loads(content)
|
247 |
+
table_data = [
|
248 |
+
["學測架構|內容(Content)", data['content']['level'], data['content']['explanation']],
|
249 |
+
["學測架構|組織(Organization)", data['organization']['level'], data['organization']['explanation']],
|
250 |
+
["學測架構|文法、句構(Grammar/Sentence Structure)", data['grammar_and_usage']['level'], data['grammar_and_usage']['explanation']],
|
251 |
+
["學測架構|字彙、拼字(Vocabulary/Spelling)", data['vocabulary']['level'], data['vocabulary']['explanation']],
|
252 |
+
["JUTOR 架構|連貫性和連接詞(Coherence and Cohesion)", data['coherence_and_cohesion']['level'], data['coherence_and_cohesion']['explanation']]
|
253 |
+
]
|
254 |
+
headers = ["架構", "評分", "解釋"]
|
255 |
+
gr_update = gr.update(value=table_data, headers=headers)
|
256 |
+
|
257 |
+
return gr_update
|
258 |
+
|
259 |
|
260 |
def generate_correct_grammatical_spelling_errors(eng_level, paragraph, user_correct_grammatical_spelling_errors_prompt):
|
261 |
"""
|
|
|
270 |
{"role": "system", "content": paragraph},
|
271 |
{"role": "user", "content": user_content}
|
272 |
]
|
|
|
273 |
response_format = { "type": "json_object" }
|
|
|
274 |
request_payload = {
|
275 |
"model": "gpt-3.5-turbo",
|
276 |
"messages": messages,
|
277 |
+
"max_tokens": 1000,
|
278 |
"response_format": response_format
|
279 |
}
|
280 |
|
281 |
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
282 |
content = response.choices[0].message.content
|
283 |
+
data = json.loads(content)
|
284 |
+
print(f"data: {data}")
|
285 |
+
|
286 |
+
corrections_list = [
|
287 |
+
[item['original'], item['correction'], item['explanation']]
|
288 |
+
for item in data['Corrections and Explanations']
|
289 |
+
]
|
290 |
+
headers = ["原文", "更正", "解釋"]
|
291 |
+
|
292 |
+
corrections_list_gr_update = gr.update(value=corrections_list, headers=headers, wrap=True)
|
293 |
+
reverse_paragraph_gr_update = gr.update(value=data["Revised Paragraph"])
|
294 |
+
|
295 |
+
return corrections_list_gr_update, reverse_paragraph_gr_update
|
296 |
+
|
297 |
+
def diff_texts(text1, text2):
|
298 |
+
user_content = f"""
|
299 |
+
original text is {text1}
|
300 |
+
revised text is {text2}
|
301 |
+
please check the differences between the original text and the revised text.
|
302 |
+
output a HTML string only
|
303 |
+
highlight the differences with yellow background color
|
304 |
+
|
305 |
+
restriction:
|
306 |
+
- no more explanation either no more extra non-relation sentences.
|
307 |
+
|
308 |
+
EXAMPLE:
|
309 |
+
<p>Eating fruits and vegetables <span style="background-color:yellow;">are</span> important for our health. Fruits and vegetables give us the vitamins we need. They help our bodies stay strong and fight sickness. Eating them every day makes us feel better and have more energy. So, eating fruits and vegetables <span style="background-color:yellow;">keep</span> us healthy.</p>
|
310 |
+
"""
|
311 |
+
messages = [
|
312 |
+
{"role": "user", "content": user_content}
|
313 |
+
]
|
314 |
+
request_payload = {
|
315 |
+
"model": "gpt-3.5-turbo",
|
316 |
+
"messages": messages,
|
317 |
+
"max_tokens": 1000,
|
318 |
+
}
|
319 |
+
|
320 |
+
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
321 |
+
content = response.choices[0].message.content
|
322 |
+
|
323 |
+
print("====diff_texts====")
|
324 |
+
print(content)
|
325 |
|
326 |
return content
|
327 |
|
328 |
+
def update_paragraph_correct_grammatical_spelling_errors_input(paragraph):
|
329 |
+
return paragraph
|
330 |
+
|
331 |
def generate_refine_paragraph(eng_level, paragraph, user_refine_paragraph_prompt):
|
332 |
"""
|
333 |
根据用户输入的段落,调用OpenAI API生成相关的段落改善建议。
|
|
|
356 |
|
357 |
return content
|
358 |
|
359 |
+
|
360 |
+
|
361 |
def paragraph_save_and_tts(paragraph_text):
|
362 |
"""
|
363 |
Saves the paragraph text and generates an audio file using OpenAI's TTS.
|
|
|
574 |
Restrictions:
|
575 |
- avoiding overly technical language.
|
576 |
- Total word-count is around 50. no more explanation either no more extra non-relation sentences.
|
577 |
+
- just output supporting sentences, don't output topic sentence at this step.
|
578 |
|
579 |
EXAMPLE:
|
580 |
- Washing your hands often helps you stay healthy. It removes dirt and germs that can make you sick. Clean hands prevent the spread of diseases. You protect yourself and others by washing your hands regularly.
|
|
|
723 |
- Fair (2-1 points): Identify if the theme is unclear or if the majority of the narrative is undeveloped or irrelevant to the theme.
|
724 |
- Poor (0 points): Determine if the response is off-topic or not written at all. Remember that any response that is off-topic or unwritten should receive zero points in all aspects.
|
725 |
|
726 |
+
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's content meets the criteria.
|
727 |
+
Translate your feedback into Traditional Chinese (zh-tw) as the final result (#中文解釋 zh-TW).
|
728 |
|
729 |
評分結果以 JSON 格式輸出: content: {
|
730 |
+
"level": "#Excellent(5-4 pts)/Good(3 pts)/Fair(2-1 pts)/Poor(0 pts)",
|
731 |
+
"explanation": "#中文解釋 zh-TW"
|
732 |
}
|
733 |
|
734 |
-- 根據上述的文章,以「組織(organization)」層面評分。
|
|
|
742 |
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's Organization meets the criteria. Translate your feedback into Traditional Chinese (zh_tw) as the final result (#中文解釋).
|
743 |
|
744 |
評分結果以 JSON 格式輸出: organization: {
|
745 |
+
"level": "#Excellent(5-4 pts)/Good(3 pts)/Fair(2-1 pts)/Poor(0 pts)",
|
746 |
+
"explanation": "#中文解釋 zh-TW"
|
747 |
}
|
748 |
|
749 |
-- 根據上述的文章,以「文法和用法(Grammar and usage)」層面評分。
|
|
|
757 |
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's Grammar/Sentence Structure meets the criteria. Translate your feedback into Traditional Chinese (zh_tw) as the final result (#中文解釋).
|
758 |
|
759 |
評分結果以 JSON 格式輸出: grammar_and_usage: {
|
760 |
+
"level": "#Excellent(5-4 pts)/Good(3 pts)/Fair(2-1 pts)/Poor(0 pts)",
|
761 |
+
"explanation": "#中文解釋 zh-TW"
|
762 |
}
|
763 |
|
764 |
-- 根據上述的文章,以「詞彙(Vocabulary )」層面評分。
|
|
|
772 |
Your detailed feedback should explain the score you assign, including specific examples from the text to illustrate how well the student's Vocabulary/Spelling meets the criteria. Translate your feedback into Traditional Chinese (zh_tw) as the final result (#中文解釋).
|
773 |
|
774 |
評分結果以 JSON 格式輸出: vocabulary: {
|
775 |
+
"level": "#Excellent(5-4 pts)/Good(3 pts)/Fair(2-1 pts)/Poor(0 pts)",
|
776 |
+
"explanation": "#中文解釋 zh-TW"
|
777 |
}
|
778 |
|
779 |
-- 根據上述的文章,以「連貫性和連接詞(Coherence and Cohesion)」層面評分。
|
780 |
- 評分等級有三級:beginner, intermediate, advanced.
|
781 |
- 以繁體中文 zh-TW 解釋
|
782 |
評分結果以 JSON 格式輸出: coherence_and_cohesion: {
|
783 |
+
"level": "#beginner/intermediate/advanced",
|
784 |
+
"explanation": "#中文解釋 zh-TW"
|
785 |
}
|
786 |
|
787 |
+
Restrictions:
|
788 |
+
- the _explanation should be in Traditional Chinese (zh-TW), it's very important.
|
789 |
+
|
790 |
Final Output JSON Format:
|
791 |
{{
|
792 |
“content“: {{content’s dict}},
|
|
|
800 |
with gr.Row():
|
801 |
generate_paragraph_evaluate_button = gr.Button("段落分析", variant="primary")
|
802 |
with gr.Row():
|
803 |
+
paragraph_evaluate_output = gr.Dataframe(label="完整段落分析", wrap=True)
|
804 |
|
805 |
+
# 修訂文法與拼字錯誤
|
806 |
+
with gr.Row():
|
807 |
+
with gr.Column():
|
808 |
+
with gr.Row() as paragraph_correct_grammatical_spelling_errors_params:
|
809 |
+
default_user_correct_grammatical_spelling_errors_prompt = """
|
810 |
+
I'm aiming to improve my writing.
|
811 |
+
Please assist me by "Correcting Grammatical and Spelling Errors" in the provided paragraph.
|
812 |
+
For every correction you make, I'd like an "Explanation" to understand the reasoning behind it.
|
813 |
+
- Paragraph for Correction: [paragraph split by punctuation mark]
|
814 |
+
- The sentence to remain unchanged: [sentence_to_remain_unchanged]
|
815 |
+
- When explaining, use Traditional Chinese (Taiwan, 繁體中文) for clarity.
|
816 |
+
- But others(original, Correction, revised_paragraph) in English.
|
817 |
+
- Make sure any revised vocabulary aligns with the eng_level.
|
818 |
+
- Guidelines for Length and Complexity: Please keep explanations concise and straightforward,
|
819 |
+
- Avoiding overly technical language.
|
820 |
+
The response should strictly be in the below JSON format and nothing else:
|
821 |
+
|
822 |
+
EXAMPLE:
|
823 |
+
{{
|
824 |
+
"Corrections and Explanations": [
|
825 |
+
{{ "original": "# original_sentence1", "correction": "#correction_1", "explanation": "#explanation_1(in_traditional_chinese ZH-TW)" }},
|
826 |
+
{{ "original": "# original_sentence2", "correction": "#correction_2", "explanation": "#explanation_2(in_traditional_chinese ZH-TW)" }},
|
827 |
+
...
|
828 |
+
],
|
829 |
+
"Revised Paragraph": "#revised_paragraph"
|
830 |
+
}}
|
831 |
+
"""
|
832 |
+
user_correct_grammatical_spelling_errors_prompt = gr.Textbox(label="Correct Grammatical and Spelling Errors Prompt", value=default_user_correct_grammatical_spelling_errors_prompt, visible=False)
|
833 |
+
|
834 |
+
with gr.Row() as paragraph_correct_grammatical_spelling_errors_html:
|
835 |
+
gr.Markdown("# Step 8. 修訂文法與拼字錯誤")
|
836 |
+
with gr.Row():
|
837 |
+
with gr.Column():
|
838 |
+
gr.Markdown("## 修訂文法與拼字錯誤(Correct Grammatical and Spelling Errors)")
|
839 |
+
with gr.Column():
|
840 |
+
with gr.Accordion("參考指引:AI 的混淆狀況?", open=False):
|
841 |
+
gr.Markdown("""
|
842 |
+
- 段落寫作的過程,如果全程採用 JUTOR 的建議例句,則不會有文法與拼字錯誤。JUTOR 有時後仍會挑出一些字詞修訂,並非原本字詞錯誤,而是改換不同說法,你可以參考。
|
843 |
+
- 若是自行完成段落寫作,則不會發生自我修訂的混淆狀況。
|
844 |
+
""")
|
845 |
+
with gr.Row():
|
846 |
+
with gr.Column():
|
847 |
+
paragraph_correct_grammatical_spelling_errors_input = gr.Textbox(label="這是你的原始寫作內容,參考 JUTOR 的改正,你可以選擇是否修改:")
|
848 |
+
with gr.Column():
|
849 |
+
generate_correct_grammatical_spelling_errors_button = gr.Button("JUTOR 修訂", variant="primary")
|
850 |
+
correct_grammatical_spelling_errors_output = gr.Dataframe(label="修訂文法與拼字錯誤")
|
851 |
+
revised_paragraph_output = gr.Textbox(label="Revised Paragraph", show_copy_button=True)
|
852 |
+
revised_paragraph_diff = gr.HTML()
|
853 |
+
|
854 |
+
generate_correct_grammatical_spelling_errors_button.click(
|
855 |
+
fn=generate_correct_grammatical_spelling_errors,
|
856 |
+
inputs=[
|
857 |
+
eng_level_input,
|
858 |
+
paragraph_output,
|
859 |
+
user_correct_grammatical_spelling_errors_prompt,
|
860 |
+
],
|
861 |
+
outputs=[
|
862 |
+
correct_grammatical_spelling_errors_output,
|
863 |
+
revised_paragraph_output
|
864 |
+
]
|
865 |
+
).then(
|
866 |
+
fn=diff_texts,
|
867 |
+
inputs=[paragraph_output, revised_paragraph_output],
|
868 |
+
outputs=revised_paragraph_diff
|
869 |
+
).then(
|
870 |
+
fn=update_paragraph_correct_grammatical_spelling_errors_input,
|
871 |
+
inputs=[paragraph_output],
|
872 |
+
outputs=paragraph_correct_grammatical_spelling_errors_input
|
873 |
+
)
|
874 |
|
875 |
gr.Markdown("## 10. Refine Paragraph 段落改善建議")
|
876 |
default_user_refine_paragraph_prompt = """
|
|
|
878 |
- Revised Version 1 (for correction): paragraph_ai_modification(split by punctuation mark)
|
879 |
- Do not modify the sentence: topicSentence"
|
880 |
- Make sure any revised vocabulary aligns with the eng_level.
|
881 |
+
- When explaining, use Traditional Chinese (Taiwan, 繁體中文 zh-TW) for clarity.
|
882 |
- But others(Origin, Suggestion, revised_paragraph_v2) use English, that's very important.
|
883 |
- Guidelines for Length and Complexity:
|
884 |
Please keep explanations concise and straightforward,
|
|
|
886 |
The response should strictly be in the below JSON format and nothing else:
|
887 |
{
|
888 |
"Suggestions and Explanations": [
|
889 |
+
{ "Origin": "#original_text_1", "Suggestion": "#suggestion_1", "Explanation": "#explanation_1(in_traditional_chinese zh-TW)" },
|
890 |
+
{ "Origin": "#original_text_2", "Suggestion": "#suggestion_2", "Explanation": "#explanation_2(in_traditional_chinese zh-TW)" },
|
891 |
... ],
|
892 |
"Revised Paragraph": "#revised_paragraph_v2"
|
893 |
}
|
|
|
987 |
outputs=paragraph_evaluate_output
|
988 |
)
|
989 |
|
990 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
991 |
|
992 |
generate_refine_paragraph_button.click(
|
993 |
fn=generate_refine_paragraph,
|