Spaces:
Running
Running
refactor UXUI at full paragraph
Browse files
app.py
CHANGED
@@ -881,7 +881,6 @@ def generate_correct_grammatical_spelling_errors(model, max_tokens, sys_content,
|
|
881 |
error_msg = "選擇的模型不存在或無法存取"
|
882 |
raise gr.Error(error_msg)
|
883 |
|
884 |
-
|
885 |
def highlight_diff_texts(highlight_list, text):
|
886 |
"""
|
887 |
將文本中需要高亮的部分用紅色標記出來
|
@@ -3250,48 +3249,49 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3250 |
with gr.Row():
|
3251 |
with gr.Column():
|
3252 |
full_paragraph_input = gr.TextArea(label="輸入段落全文")
|
3253 |
-
|
|
|
|
|
|
|
|
|
3254 |
with gr.Row():
|
3255 |
-
full_paragraph_evaluate_button = gr.Button("✨ JUTOR 段落全文分析", variant="primary")
|
3256 |
with gr.Row():
|
3257 |
full_paragraph_evaluate_output = gr.Dataframe(label="段落全文分析", wrap=True, column_widths=[35, 15, 50], interactive=False)
|
3258 |
|
3259 |
-
|
3260 |
-
|
3261 |
-
|
3262 |
-
|
3263 |
-
|
3264 |
-
|
3265 |
-
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
|
3287 |
# 寫作完成
|
3288 |
with gr.Row():
|
3289 |
-
gr.Markdown("#
|
3290 |
-
with gr.Row():
|
3291 |
-
full_paragraph_save_button = gr.Button("輸出結果", variant="primary")
|
3292 |
with gr.Row():
|
3293 |
-
full_paragraph_save_output = gr.TextArea(label="
|
3294 |
-
full_audio_output = gr.Audio(label="音檔", type="filepath")
|
3295 |
|
3296 |
# 建立歷程回顧
|
3297 |
with gr.Row():
|
@@ -3314,12 +3314,73 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3314 |
full_paragraph_refine_input_history = gr.Markdown()
|
3315 |
gr.Markdown("<span style='color:#4e80ee'>段落改善建議</span>")
|
3316 |
full_paragraph_refine_output_table_history = gr.Dataframe(wrap=True, interactive=False, column_widths=[30, 30, 40])
|
3317 |
-
|
3318 |
-
gr.Markdown("<span style='color:#4e80ee'
|
3319 |
full_paragraph_refine_output_history = gr.Markdown()
|
3320 |
-
gr.Markdown("<span style='color:#4e80ee'
|
3321 |
full_paragraph_save_output_history = gr.Markdown()
|
3322 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3323 |
full_paragraph_evaluate_button.click(
|
3324 |
fn=generate_paragraph_evaluate,
|
3325 |
inputs=[
|
@@ -3334,7 +3395,8 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3334 |
inputs=[full_paragraph_input],
|
3335 |
outputs=full_paragraph_correct_grammatical_spelling_errors_input
|
3336 |
)
|
3337 |
-
|
|
|
3338 |
generate_full_paragraph_correct_grammatical_spelling_errors_button.click(
|
3339 |
fn=generate_correct_grammatical_spelling_errors,
|
3340 |
inputs=[
|
@@ -3355,6 +3417,7 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3355 |
outputs=full_paragraph_refine_input
|
3356 |
)
|
3357 |
|
|
|
3358 |
generate_full_paragraph_refine_button.click(
|
3359 |
fn=generate_refine_paragraph,
|
3360 |
inputs=[
|
@@ -3377,12 +3440,6 @@ with gr.Blocks(theme=THEME, css=CSS) as demo:
|
|
3377 |
]
|
3378 |
)
|
3379 |
|
3380 |
-
full_paragraph_save_button.click(
|
3381 |
-
fn=paragraph_save_and_tts,
|
3382 |
-
inputs=[full_paragraph_refine_input],
|
3383 |
-
outputs=[full_paragraph_save_output, full_audio_output]
|
3384 |
-
)
|
3385 |
-
|
3386 |
full_paragraph_history_save_button.click(
|
3387 |
fn=generate_paragraph_evaluate_history,
|
3388 |
inputs=[
|
|
|
881 |
error_msg = "選擇的模型不存在或無法存取"
|
882 |
raise gr.Error(error_msg)
|
883 |
|
|
|
884 |
def highlight_diff_texts(highlight_list, text):
|
885 |
"""
|
886 |
將文本中需要高亮的部分用紅色標記出來
|
|
|
3249 |
with gr.Row():
|
3250 |
with gr.Column():
|
3251 |
full_paragraph_input = gr.TextArea(label="輸入段落全文")
|
3252 |
+
with gr.Row():
|
3253 |
+
full_paragraph_ai_analysis_button = gr.Button("✨ JUTOR 分析", variant="primary")
|
3254 |
+
|
3255 |
+
with gr.Tabs():
|
3256 |
+
with gr.TabItem("JUTOR 段落全文分析"):
|
3257 |
with gr.Row():
|
3258 |
+
full_paragraph_evaluate_button = gr.Button("✨ JUTOR 段落全文分析", variant="primary", visible=False)
|
3259 |
with gr.Row():
|
3260 |
full_paragraph_evaluate_output = gr.Dataframe(label="段落全文分析", wrap=True, column_widths=[35, 15, 50], interactive=False)
|
3261 |
|
3262 |
+
with gr.TabItem("JUTOR 修訂文法與拼字錯誤"):
|
3263 |
+
# JUTOR 段落批改與整體建議
|
3264 |
+
with gr.Row():
|
3265 |
+
full_paragraph_correct_grammatical_spelling_errors_input = gr.TextArea(label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否修改:", visible=False)
|
3266 |
+
with gr.Row():
|
3267 |
+
with gr.Column():
|
3268 |
+
generate_full_paragraph_correct_grammatical_spelling_errors_button = gr.Button("✨ JUTOR 修訂文法與拼字錯誤", variant="primary", visible=False)
|
3269 |
+
full_paragraph_correct_grammatical_spelling_errors_output_table = gr.Dataframe(label="修訂文法與拼字錯誤", interactive=False, column_widths=[30, 30, 40])
|
3270 |
+
revised_full_paragraph_output = gr.Textbox(label="Revised Paragraph", show_copy_button=True, visible=False)
|
3271 |
+
gr.Markdown("## 修訂建議")
|
3272 |
+
revised_full_paragraph_diff = gr.HTML()
|
3273 |
+
with gr.TabItem("JUTOR 段落改善建議"):
|
3274 |
+
# JUTOR 段落批改與整體建議
|
3275 |
+
with gr.Row():
|
3276 |
+
full_paragraph_refine_input = gr.TextArea(label="這是你的原始寫作內容,參考 JUTOR 的建議,你可以選擇是否��改:", show_copy_button=True, visible=False)
|
3277 |
+
with gr.Row():
|
3278 |
+
with gr.Column():
|
3279 |
+
with gr.Row():
|
3280 |
+
generate_full_paragraph_refine_button = gr.Button("✨ JUTOR 段落改善建議", variant="primary", visible=False)
|
3281 |
+
full_paragraph_refine_output_table = gr.DataFrame(label="段落改善建議", wrap=True, interactive=False)
|
3282 |
+
with gr.Row():
|
3283 |
+
gr.Markdown("## 修改建議")
|
3284 |
+
with gr.Row():
|
3285 |
+
with gr.Column(scale=2):
|
3286 |
+
full_paragraph_refine_output = gr.HTML(label="修改建議", visible=True)
|
3287 |
+
with gr.Column(scale=1):
|
3288 |
+
full_paragraph_refine_output_audio = gr.Audio(label="音檔", type="filepath")
|
3289 |
|
3290 |
# 寫作完成
|
3291 |
with gr.Row():
|
3292 |
+
gr.Markdown("# 自行根據建議修改")
|
|
|
|
|
3293 |
with gr.Row():
|
3294 |
+
full_paragraph_save_output = gr.TextArea(label="自行修改結果")
|
|
|
3295 |
|
3296 |
# 建立歷程回顧
|
3297 |
with gr.Row():
|
|
|
3314 |
full_paragraph_refine_input_history = gr.Markdown()
|
3315 |
gr.Markdown("<span style='color:#4e80ee'>段落改善建議</span>")
|
3316 |
full_paragraph_refine_output_table_history = gr.Dataframe(wrap=True, interactive=False, column_widths=[30, 30, 40])
|
3317 |
+
|
3318 |
+
gr.Markdown("<span style='color:#4e80ee'>AI 修改建議</span>")
|
3319 |
full_paragraph_refine_output_history = gr.Markdown()
|
3320 |
+
gr.Markdown("<span style='color:#4e80ee'>自行修改結果</span>")
|
3321 |
full_paragraph_save_output_history = gr.Markdown()
|
3322 |
+
|
3323 |
+
# JUTOR 分析
|
3324 |
+
full_paragraph_ai_analysis_button.click(
|
3325 |
+
fn=duplicate_element,
|
3326 |
+
inputs=full_paragraph_input,
|
3327 |
+
outputs=full_paragraph_correct_grammatical_spelling_errors_input
|
3328 |
+
).then(
|
3329 |
+
fn=duplicate_element,
|
3330 |
+
inputs=full_paragraph_input,
|
3331 |
+
outputs=full_paragraph_refine_input
|
3332 |
+
).then(
|
3333 |
+
# 段落全文分析
|
3334 |
+
fn=generate_paragraph_evaluate,
|
3335 |
+
inputs=[
|
3336 |
+
model,
|
3337 |
+
max_tokens,
|
3338 |
+
full_paragraph_sys_content_input,
|
3339 |
+
full_paragraph_input
|
3340 |
+
],
|
3341 |
+
outputs=full_paragraph_evaluate_output
|
3342 |
+
).then(
|
3343 |
+
# 修訂文法與拼字錯誤
|
3344 |
+
fn=generate_correct_grammatical_spelling_errors,
|
3345 |
+
inputs=[
|
3346 |
+
model,
|
3347 |
+
max_tokens,
|
3348 |
+
full_paragraph_sys_content_input,
|
3349 |
+
eng_level_input,
|
3350 |
+
full_paragraph_correct_grammatical_spelling_errors_input,
|
3351 |
+
],
|
3352 |
+
outputs=[
|
3353 |
+
full_paragraph_correct_grammatical_spelling_errors_output_table,
|
3354 |
+
revised_full_paragraph_output
|
3355 |
+
]
|
3356 |
+
).then(
|
3357 |
+
fn=highlight_diff_texts,
|
3358 |
+
inputs=[full_paragraph_correct_grammatical_spelling_errors_output_table, revised_full_paragraph_output],
|
3359 |
+
outputs=revised_full_paragraph_diff
|
3360 |
+
).then(
|
3361 |
+
# 段落改善建議
|
3362 |
+
fn=generate_refine_paragraph,
|
3363 |
+
inputs=[
|
3364 |
+
model,
|
3365 |
+
max_tokens,
|
3366 |
+
full_paragraph_sys_content_input,
|
3367 |
+
eng_level_input,
|
3368 |
+
full_paragraph_refine_input,
|
3369 |
+
],
|
3370 |
+
outputs=[
|
3371 |
+
full_paragraph_refine_output_table,
|
3372 |
+
full_paragraph_refine_output,
|
3373 |
+
]
|
3374 |
+
).then(
|
3375 |
+
fn=paragraph_save_and_tts,
|
3376 |
+
inputs=[full_paragraph_refine_output],
|
3377 |
+
outputs=[
|
3378 |
+
full_paragraph_refine_output,
|
3379 |
+
full_paragraph_refine_output_audio
|
3380 |
+
]
|
3381 |
+
)
|
3382 |
+
|
3383 |
+
# 段落全文分析
|
3384 |
full_paragraph_evaluate_button.click(
|
3385 |
fn=generate_paragraph_evaluate,
|
3386 |
inputs=[
|
|
|
3395 |
inputs=[full_paragraph_input],
|
3396 |
outputs=full_paragraph_correct_grammatical_spelling_errors_input
|
3397 |
)
|
3398 |
+
|
3399 |
+
# 修訂文法與拼字錯誤
|
3400 |
generate_full_paragraph_correct_grammatical_spelling_errors_button.click(
|
3401 |
fn=generate_correct_grammatical_spelling_errors,
|
3402 |
inputs=[
|
|
|
3417 |
outputs=full_paragraph_refine_input
|
3418 |
)
|
3419 |
|
3420 |
+
# 段落改善建議
|
3421 |
generate_full_paragraph_refine_button.click(
|
3422 |
fn=generate_refine_paragraph,
|
3423 |
inputs=[
|
|
|
3440 |
]
|
3441 |
)
|
3442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3443 |
full_paragraph_history_save_button.click(
|
3444 |
fn=generate_paragraph_evaluate_history,
|
3445 |
inputs=[
|