Spaces:
Sleeping
Sleeping
## 🌟 主題:{{title}} (如果沒有 title 就省略)
Browse files
app.py
CHANGED
@@ -888,7 +888,8 @@ def get_video_id_summary(video_id, df_string, source):
|
|
888 |
# 检查 summary_file 是否存在
|
889 |
is_summary_file_exists = GCS_SERVICE.check_file_exists(bucket_name, summary_file_blob_name)
|
890 |
if not is_summary_file_exists:
|
891 |
-
|
|
|
892 |
summary_json = {"summary": str(summary)}
|
893 |
summary_text = json.dumps(summary_json, ensure_ascii=False, indent=2)
|
894 |
upload_file_to_gcs_with_json_string(gcs_client, bucket_name, summary_file_blob_name, summary_text)
|
@@ -909,7 +910,8 @@ def get_video_id_summary(video_id, df_string, source):
|
|
909 |
# 检查逐字稿是否存在
|
910 |
exists, file_id = check_file_exists(service, folder_id, file_name)
|
911 |
if not exists:
|
912 |
-
|
|
|
913 |
summary_json = {"summary": str(summary)}
|
914 |
summary_text = json.dumps(summary_json, ensure_ascii=False, indent=2)
|
915 |
|
@@ -930,12 +932,27 @@ def get_video_id_summary(video_id, df_string, source):
|
|
930 |
|
931 |
return summary_json
|
932 |
|
933 |
-
def generate_summarise(df_string):
|
934 |
# 使用 OpenAI 生成基于上传数据的问题
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
935 |
sys_content = "你是一個擅長資料分析跟影片教學的老師,user 為學生,請精讀資料文本,自行判斷資料的種類,使用 zh-TW"
|
936 |
user_content = f"""
|
937 |
-
|
|
|
|
|
|
|
|
|
|
|
938 |
格式為 Markdown
|
|
|
939 |
整體摘要在一百字以內
|
940 |
重點概念列出 bullet points,至少三個,最多五個
|
941 |
以及可能的結論與結尾延伸小問題提供學生作反思
|
@@ -943,6 +960,7 @@ def generate_summarise(df_string):
|
|
943 |
加減乘除、根號、次方等等的運算式口語也換成 LATEX 數學符號
|
944 |
|
945 |
整體格式為:
|
|
|
946 |
## 📚 整體摘要
|
947 |
- (一個 bullet point....)
|
948 |
|
@@ -955,7 +973,7 @@ def generate_summarise(df_string):
|
|
955 |
- (一個 bullet point....)
|
956 |
|
957 |
## ❓ 延伸小問題
|
958 |
-
- (一個 bullet point
|
959 |
"""
|
960 |
|
961 |
# 🗂️ 1. 內容類型:?
|
@@ -1539,7 +1557,8 @@ def create_LLM_content(video_id, df_string, kind):
|
|
1539 |
content = generate_reading_passage(df_string)
|
1540 |
update_LLM_content(video_id, content, kind)
|
1541 |
elif kind == "summary_markdown":
|
1542 |
-
|
|
|
1543 |
update_LLM_content(video_id, content, kind)
|
1544 |
elif kind == "mind_map":
|
1545 |
content = generate_mind_map(df_string)
|
|
|
888 |
# 检查 summary_file 是否存在
|
889 |
is_summary_file_exists = GCS_SERVICE.check_file_exists(bucket_name, summary_file_blob_name)
|
890 |
if not is_summary_file_exists:
|
891 |
+
meta_data = get_meta_data(video_id)
|
892 |
+
summary = generate_summarise(df_string, meta_data)
|
893 |
summary_json = {"summary": str(summary)}
|
894 |
summary_text = json.dumps(summary_json, ensure_ascii=False, indent=2)
|
895 |
upload_file_to_gcs_with_json_string(gcs_client, bucket_name, summary_file_blob_name, summary_text)
|
|
|
910 |
# 检查逐字稿是否存在
|
911 |
exists, file_id = check_file_exists(service, folder_id, file_name)
|
912 |
if not exists:
|
913 |
+
meta_data = get_meta_data(video_id)
|
914 |
+
summary = generate_summarise(df_string, meta_data)
|
915 |
summary_json = {"summary": str(summary)}
|
916 |
summary_text = json.dumps(summary_json, ensure_ascii=False, indent=2)
|
917 |
|
|
|
932 |
|
933 |
return summary_json
|
934 |
|
935 |
+
def generate_summarise(df_string, metadata=None):
|
936 |
# 使用 OpenAI 生成基于上传数据的问题
|
937 |
+
if metadata:
|
938 |
+
title = metadata.get("title", "")
|
939 |
+
subject = metadata.get("subject", "")
|
940 |
+
grade = metadata.get("grade", "")
|
941 |
+
else:
|
942 |
+
title = ""
|
943 |
+
subject = ""
|
944 |
+
grade = ""
|
945 |
+
|
946 |
sys_content = "你是一個擅長資料分析跟影片教學的老師,user 為學生,請精讀資料文本,自行判斷資料的種類,使用 zh-TW"
|
947 |
user_content = f"""
|
948 |
+
課程名稱:{title}
|
949 |
+
科目:{subject}
|
950 |
+
年級:{grade}
|
951 |
+
|
952 |
+
請根據內文: {df_string}
|
953 |
+
|
954 |
格式為 Markdown
|
955 |
+
如果有課程名稱,請圍繞「課程名稱」為學習重點,進行重點整理,不要整理跟情境故事相關的問題
|
956 |
整體摘要在一百字以內
|
957 |
重點概念列出 bullet points,至少三個,最多五個
|
958 |
以及可能的結論與結尾延伸小問題提供學生作反思
|
|
|
960 |
加減乘除、根號、次方等等的運算式口語也換成 LATEX 數學符號
|
961 |
|
962 |
整體格式為:
|
963 |
+
## 🌟 主題:{{title}} (如果沒有 title 就省略)
|
964 |
## 📚 整體摘要
|
965 |
- (一個 bullet point....)
|
966 |
|
|
|
973 |
- (一個 bullet point....)
|
974 |
|
975 |
## ❓ 延伸小問題
|
976 |
+
- (一個 bullet point....請圍繞「課程名稱」為學習重點,進行重點整理,不要整理跟情境故事相關的問題)
|
977 |
"""
|
978 |
|
979 |
# 🗂️ 1. 內容類型:?
|
|
|
1557 |
content = generate_reading_passage(df_string)
|
1558 |
update_LLM_content(video_id, content, kind)
|
1559 |
elif kind == "summary_markdown":
|
1560 |
+
meta_data = get_meta_data(video_id)
|
1561 |
+
content = generate_summarise(df_string, meta_data)
|
1562 |
update_LLM_content(video_id, content, kind)
|
1563 |
elif kind == "mind_map":
|
1564 |
content = generate_mind_map(df_string)
|