Spaces:
Sleeping
Sleeping
def get_log_session_content(file_name):
Browse files
app.py
CHANGED
@@ -11,6 +11,8 @@ import pytz
|
|
11 |
import json
|
12 |
import tempfile
|
13 |
import urllib.parse
|
|
|
|
|
14 |
|
15 |
from storage_service import GoogleCloudStorage
|
16 |
|
@@ -634,10 +636,42 @@ def get_log_session_content(file_name):
|
|
634 |
content = GCS_SERVICE.download_as_string("jutor_logs", file_name)
|
635 |
print(f"content: {content}")
|
636 |
content_json = json.loads(content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
else:
|
638 |
-
|
639 |
-
|
640 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
|
642 |
|
643 |
# === Chinese ===
|
@@ -772,8 +806,6 @@ def init_params(request: gr.Request):
|
|
772 |
# session timestamp 用 2024-01-01-12-00-00 格式, 要用 UTC+8 時間
|
773 |
session_timestamp = datetime.now(pytz.utc).astimezone(pytz.timezone('Asia/Taipei')).strftime("%Y-%m-%d-%H-%M-%S")
|
774 |
|
775 |
-
|
776 |
-
|
777 |
if "language" in query_params:
|
778 |
if query_params["language"] == "english":
|
779 |
print(f"language: english")
|
@@ -2010,7 +2042,26 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
2010 |
get_paragraph_logs_button = gr.Button("取得英文段落練習歷程")
|
2011 |
paragraph_logs_session_list = gr.Radio(label="歷程時間列表")
|
2012 |
with gr.Column(scale=3):
|
2013 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014 |
|
2015 |
get_paragraph_logs_button.click(
|
2016 |
fn=get_logs_sessions,
|
@@ -2021,7 +2072,19 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
|
|
2021 |
paragraph_logs_session_list.select(
|
2022 |
fn=get_log_session_content,
|
2023 |
inputs=[paragraph_logs_session_list],
|
2024 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025 |
)
|
2026 |
|
2027 |
|
|
|
11 |
import json
|
12 |
import tempfile
|
13 |
import urllib.parse
|
14 |
+
import pandas as pd
|
15 |
+
|
16 |
|
17 |
from storage_service import GoogleCloudStorage
|
18 |
|
|
|
636 |
content = GCS_SERVICE.download_as_string("jutor_logs", file_name)
|
637 |
print(f"content: {content}")
|
638 |
content_json = json.loads(content)
|
639 |
+
paragraph_log_topic_input_history = content_json["topic_output"]
|
640 |
+
paragraph_log_points_input_history = content_json["points_output"]
|
641 |
+
paragraph_log_topic_sentence_input_history = content_json["topic_sentence_input"]
|
642 |
+
paragraph_log_supporting_sentences_input_history = content_json["supporting_sentences_input"]
|
643 |
+
paragraph_log_conclusion_sentence_input_history = content_json["conclusion_sentence_input"]
|
644 |
+
paragraph_log_paragraph_output_history = content_json["paragraph_output"]
|
645 |
+
# to df
|
646 |
+
paragraph_log_paragraph_evaluate_output_history = pd.DataFrame(content_json["paragraph_evaluate_output"])
|
647 |
+
paragraph_log_correct_grammatical_spelling_errors_output_table_history = pd.DataFrame(content_json["correct_grammatical_spelling_errors_output_table"])
|
648 |
+
paragraph_log_refine_output_table_history = pd.DataFrame(content_json["refine_output_table"])
|
649 |
+
paragraph_log_refine_output_history = content_json["refine_output"]
|
650 |
+
paragraph_log_paragraph_save_output = content_json["paragraph_output"]
|
651 |
else:
|
652 |
+
paragraph_log_topic_input_history = ""
|
653 |
+
paragraph_log_points_input_history = ""
|
654 |
+
paragraph_log_topic_sentence_input_history = ""
|
655 |
+
paragraph_log_supporting_sentences_input_history = ""
|
656 |
+
paragraph_log_conclusion_sentence_input_history = ""
|
657 |
+
paragraph_log_paragraph_output_history = ""
|
658 |
+
paragraph_log_paragraph_evaluate_output_history = pd.DataFrame()
|
659 |
+
paragraph_log_correct_grammatical_spelling_errors_output_table_history = pd.DataFrame()
|
660 |
+
paragraph_log_refine_output_table_history = pd.DataFrame()
|
661 |
+
paragraph_log_refine_output_history = ""
|
662 |
+
paragraph_log_paragraph_save_output = ""
|
663 |
+
|
664 |
+
return paragraph_log_topic_input_history, \
|
665 |
+
paragraph_log_points_input_history, \
|
666 |
+
paragraph_log_topic_sentence_input_history, \
|
667 |
+
paragraph_log_supporting_sentences_input_history, \
|
668 |
+
paragraph_log_conclusion_sentence_input_history, \
|
669 |
+
paragraph_log_paragraph_output_history, \
|
670 |
+
paragraph_log_paragraph_evaluate_output_history, \
|
671 |
+
paragraph_log_correct_grammatical_spelling_errors_output_table_history, \
|
672 |
+
paragraph_log_refine_output_table_history, \
|
673 |
+
paragraph_log_refine_output_history, \
|
674 |
+
paragraph_log_paragraph_save_output
|
675 |
|
676 |
|
677 |
# === Chinese ===
|
|
|
806 |
# session timestamp 用 2024-01-01-12-00-00 格式, 要用 UTC+8 時間
|
807 |
session_timestamp = datetime.now(pytz.utc).astimezone(pytz.timezone('Asia/Taipei')).strftime("%Y-%m-%d-%H-%M-%S")
|
808 |
|
|
|
|
|
809 |
if "language" in query_params:
|
810 |
if query_params["language"] == "english":
|
811 |
print(f"language: english")
|
|
|
2042 |
get_paragraph_logs_button = gr.Button("取得英文段落練習歷程")
|
2043 |
paragraph_logs_session_list = gr.Radio(label="歷程時間列表")
|
2044 |
with gr.Column(scale=3):
|
2045 |
+
with gr.Accordion("歷程回顧", open=True) as paragraph_logs_accordion:
|
2046 |
+
gr.Markdown("<span style='color:#4e80ee'>主題</span>")
|
2047 |
+
paragraph_log_topic_input_history = gr.Markdown(label="主題")
|
2048 |
+
gr.Markdown("<span style='color:#4e80ee'>要點/關鍵字</span>")
|
2049 |
+
paragraph_log_points_input_history = gr.Markdown(label="要點/關鍵字")
|
2050 |
+
gr.Markdown("<span style='color:#4e80ee'>主題句</span>")
|
2051 |
+
paragraph_log_topic_sentence_input_history = gr.Markdown(label="主題句")
|
2052 |
+
gr.Markdown("<span style='color:#4e80ee'>支持句</span>")
|
2053 |
+
paragraph_log_supporting_sentences_input_history = gr.Markdown(label="支持句")
|
2054 |
+
gr.Markdown("<span style='color:#4e80ee'>結論句</span>")
|
2055 |
+
paragraph_log_conclusion_sentence_input_history = gr.Markdown(label="結論句")
|
2056 |
+
gr.Markdown("<span style='color:#4e80ee'>完整段落</span>")
|
2057 |
+
paragraph_log_paragraph_output_history = gr.Markdown(label="完整段落")
|
2058 |
+
paragraph_log_paragraph_evaluate_output_history = gr.Dataframe(label="完整段落分析", wrap=True, column_widths=[35, 15, 50], interactive=False)
|
2059 |
+
paragraph_log_correct_grammatical_spelling_errors_output_table_history = gr.Dataframe(label="修訂文法與拼字錯誤", interactive=False, wrap=True, column_widths=[30, 30, 40])
|
2060 |
+
paragraph_log_refine_output_table_history = gr.Dataframe(label="段落改善建議", wrap=True, interactive=False, column_widths=[30, 30, 40])
|
2061 |
+
gr.Markdown("<span style='color:#4e80ee'>修改建議</span>")
|
2062 |
+
paragraph_log_refine_output_history = gr.Markdown(label="修改建議")
|
2063 |
+
gr.Markdown("<span style='color:#4e80ee'>修改結果</span>")
|
2064 |
+
paragraph_log_paragraph_save_output = gr.Markdown(label="最後結果")
|
2065 |
|
2066 |
get_paragraph_logs_button.click(
|
2067 |
fn=get_logs_sessions,
|
|
|
2072 |
paragraph_logs_session_list.select(
|
2073 |
fn=get_log_session_content,
|
2074 |
inputs=[paragraph_logs_session_list],
|
2075 |
+
outputs=[
|
2076 |
+
paragraph_log_topic_input_history,
|
2077 |
+
paragraph_log_points_input_history,
|
2078 |
+
paragraph_log_topic_sentence_input_history,
|
2079 |
+
paragraph_log_supporting_sentences_input_history,
|
2080 |
+
paragraph_log_conclusion_sentence_input_history,
|
2081 |
+
paragraph_log_paragraph_output_history,
|
2082 |
+
paragraph_log_paragraph_evaluate_output_history,
|
2083 |
+
paragraph_log_correct_grammatical_spelling_errors_output_table_history,
|
2084 |
+
paragraph_log_refine_output_table_history,
|
2085 |
+
paragraph_log_refine_output_history,
|
2086 |
+
paragraph_log_paragraph_save_output
|
2087 |
+
]
|
2088 |
)
|
2089 |
|
2090 |
|