Spaces:
Running
Running
inputs=[password, claude_msg, df_string_output, claude_chatbot, content_subject, content_grade, socratic_mode_btn],
Browse files
app.py
CHANGED
@@ -1638,43 +1638,44 @@ def poll_run_status(run_id, thread_id, timeout=600, poll_interval=5):
|
|
1638 |
|
1639 |
return run.status
|
1640 |
|
1641 |
-
def chat_with_claude3(password, user_message, data, chat_history, socratic_mode=False):
|
1642 |
verify_password(password)
|
1643 |
data_json = json.loads(data)
|
1644 |
for entry in data_json:
|
1645 |
entry.pop('embed_url', None) # Remove 'embed_url' if it exists
|
1646 |
entry.pop('screenshot_path', None)
|
1647 |
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
|
|
1675 |
|
1676 |
-
|
1677 |
-
|
1678 |
|
1679 |
messages = []
|
1680 |
|
@@ -1730,14 +1731,7 @@ def chat_with_claude3(password, user_message, data, chat_history, socratic_mode=
|
|
1730 |
print(f"Error: {response.status_code}")
|
1731 |
return "请求失败,请稍后再试!", chat_history
|
1732 |
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
def update_slide(direction):
|
1742 |
global TRANSCRIPTS
|
1743 |
global CURRENT_INDEX
|
@@ -2000,7 +1994,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
2000 |
# CLAUDE 模式
|
2001 |
claude_send_button.click(
|
2002 |
chat_with_claude3,
|
2003 |
-
inputs=[password, claude_msg, df_string_output, claude_chatbot, socratic_mode_btn],
|
2004 |
outputs=[claude_msg, claude_chatbot]
|
2005 |
)
|
2006 |
|
|
|
1638 |
|
1639 |
return run.status
|
1640 |
|
1641 |
+
def chat_with_claude3(password, user_message, data, chat_history, content_subject, content_grade, socratic_mode=False):
|
1642 |
verify_password(password)
|
1643 |
data_json = json.loads(data)
|
1644 |
for entry in data_json:
|
1645 |
entry.pop('embed_url', None) # Remove 'embed_url' if it exists
|
1646 |
entry.pop('screenshot_path', None)
|
1647 |
|
1648 |
+
sys_content = f"""
|
1649 |
+
科目:{content_subject}
|
1650 |
+
年級:{content_grade}
|
1651 |
+
逐字稿資料:{trascript_text}
|
1652 |
+
-------------------------------------
|
1653 |
+
你是一個專業的{content_subject}老師, user 為{content_grade}的學生
|
1654 |
+
socratic_mode = {socratic_mode}
|
1655 |
+
if socratic_mode is True,
|
1656 |
+
- 請用蘇格拉底式的提問方式,引導學生思考,並且給予學生一些提示
|
1657 |
+
- 一次只問一個問題,字數在100字以內
|
1658 |
+
- 不要直接給予答案,讓學生自己思考
|
1659 |
+
- 但可以給予一些提示跟引導,例如給予影片的時間軸,讓學生自己去找答案
|
1660 |
+
- 在你回答的開頭標註【蘇格拉底助教:{youtube_id} 】
|
1661 |
+
|
1662 |
+
if socratic_mode is False,
|
1663 |
+
- 直接回答學生問題,字數在100字以內
|
1664 |
+
- 在你回答的開頭標註【一般學習精靈:{youtube_id} 】
|
1665 |
+
|
1666 |
+
rule:
|
1667 |
+
- 請一定要用繁體中文回答 zh-TW,並用台灣人的口語表達,回答時不用特別說明這是台灣人的語氣,也不用說這是「台語的說法」
|
1668 |
+
- 不用提到「逐字稿」這個詞
|
1669 |
+
- 如果學生問了一些問題你無法判斷,請告訴學生你無法判斷,並建議學生可以問其他問題
|
1670 |
+
- 或者你可以反問學生一些問題,幫助學生更好的理解資料,字數在100字以內
|
1671 |
+
- 如果學生的問題與資料文本無關,請告訴學生你「無法回答超出影片範圍的問題」,並告訴他可以怎麼問什麼樣的問題(一個就好)
|
1672 |
+
- 只要是參考逐字稿資料,請在回答的最後標註【參考資料:(分):(秒)】
|
1673 |
+
- 回答範圍一定要在逐字稿資料內,不要引用其他資料,請嚴格執行
|
1674 |
+
- 並在重複問句後給予學生鼓勵,讓學生有學習的動力
|
1675 |
+
- 請用 {content_grade} 的學生能懂的方式回答
|
1676 |
|
1677 |
+
"""
|
1678 |
+
|
1679 |
|
1680 |
messages = []
|
1681 |
|
|
|
1731 |
print(f"Error: {response.status_code}")
|
1732 |
return "请求失败,请稍后再试!", chat_history
|
1733 |
|
1734 |
+
# --- Slide mode ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1735 |
def update_slide(direction):
|
1736 |
global TRANSCRIPTS
|
1737 |
global CURRENT_INDEX
|
|
|
1994 |
# CLAUDE 模式
|
1995 |
claude_send_button.click(
|
1996 |
chat_with_claude3,
|
1997 |
+
inputs=[password, claude_msg, df_string_output, claude_chatbot, content_subject, content_grade, socratic_mode_btn],
|
1998 |
outputs=[claude_msg, claude_chatbot]
|
1999 |
)
|
2000 |
|