Spaces:
Running
Running
questions_answers = generate_questions_answers(df_string)
Browse files
app.py
CHANGED
@@ -1119,15 +1119,19 @@ def generate_questions_answers(df_string):
|
|
1119 |
df_string_json = json.loads(df_string)
|
1120 |
else:
|
1121 |
df_string_json = df_string
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
|
|
1126 |
|
1127 |
# JSON FORMAT: [{"question": "問題", "answer": "答案"}, ...]
|
1128 |
sys_content = "你是一個擅長資料分析跟影片教學的老師,user 為學生,請精讀資料文本,自行判斷資料的種類,並用既有資料為本質猜測用戶可能會問的問題,使用 zh-TW"
|
1129 |
user_content = f"""
|
1130 |
-
請根據 {content_text}
|
|
|
|
|
|
|
1131 |
並用 JSON 格式返回 questions_answers: [{{question: q1的敘述text, answer: q1的答案text}}, ...]
|
1132 |
k-v pair 的 key 是 question, value 是 answer
|
1133 |
"""
|
@@ -1651,7 +1655,12 @@ def create_LLM_content(video_id, df_string, kind):
|
|
1651 |
update_LLM_content(video_id, gen_content, kind)
|
1652 |
content = json.dumps(gen_content, ensure_ascii=False, indent=2)
|
1653 |
elif kind == "questions_answers":
|
1654 |
-
|
|
|
|
|
|
|
|
|
|
|
1655 |
update_LLM_content(video_id, gen_content, kind)
|
1656 |
content = json.dumps(gen_content, ensure_ascii=False, indent=2)
|
1657 |
|
|
|
1119 |
df_string_json = json.loads(df_string)
|
1120 |
else:
|
1121 |
df_string_json = df_string
|
1122 |
+
|
1123 |
+
content_text = json.dumps(df_string_json, ensure_ascii=False, indent=2)
|
1124 |
+
print("=====content_text=====")
|
1125 |
+
print(content_text)
|
1126 |
+
print("=====content_text=====")
|
1127 |
|
1128 |
# JSON FORMAT: [{"question": "問題", "answer": "答案"}, ...]
|
1129 |
sys_content = "你是一個擅長資料分析跟影片教學的老師,user 為學生,請精讀資料文本,自行判斷資料的種類,並用既有資料為本質猜測用戶可能會問的問題,使用 zh-TW"
|
1130 |
user_content = f"""
|
1131 |
+
請根據 {content_text} 生成三個問題跟答案,主要與學科有關,不要問跟情節故事相關的問題
|
1132 |
+
答案要在最後標示出處【參考:00:01:05】,請根據時間軸 start_time 來標示
|
1133 |
+
請確保問題跟答案都是繁體中文 zh-TW
|
1134 |
+
答案不用是標準答案,而是帶有啟發性的蘇格拉底式問答,讓學生思考本來的問題,以及該去參考的時間點
|
1135 |
並用 JSON 格式返回 questions_answers: [{{question: q1的敘述text, answer: q1的答案text}}, ...]
|
1136 |
k-v pair 的 key 是 question, value 是 answer
|
1137 |
"""
|
|
|
1655 |
update_LLM_content(video_id, gen_content, kind)
|
1656 |
content = json.dumps(gen_content, ensure_ascii=False, indent=2)
|
1657 |
elif kind == "questions_answers":
|
1658 |
+
if isinstance(df_string, str):
|
1659 |
+
transcript = json.loads(df_string)
|
1660 |
+
else:
|
1661 |
+
transcript = df_string
|
1662 |
+
formatted_simple_transcript = create_formatted_simple_transcript(transcript)
|
1663 |
+
gen_content = generate_questions_answers(formatted_simple_transcript)
|
1664 |
update_LLM_content(video_id, gen_content, kind)
|
1665 |
content = json.dumps(gen_content, ensure_ascii=False, indent=2)
|
1666 |
|