youngtsai commited on
Commit
2c76de1
·
1 Parent(s): 475a393

with relaxing atmosphere

Browse files
Files changed (2) hide show
  1. app.py +7 -16
  2. chatbot.py +1 -1
app.py CHANGED
@@ -1711,8 +1711,8 @@ def chat_with_opan_ai_assistant(password, youtube_id, thread_id, trascript_state
1711
  raise gr.Error(error_msg)
1712
 
1713
  try:
1714
- # assistant_id = "asst_kmvZLNkDUYaNkMNtZEAYxyPq" #GPT 4 turbo
1715
- assistant_id = "asst_5SaUElqvL3U0ybSi9PRM8x3P" #GPT 3.5 turbo
1716
 
1717
  client = OPEN_AI_CLIENT
1718
  # 直接安排逐字稿資料 in instructions
@@ -1745,7 +1745,7 @@ def chat_with_opan_ai_assistant(password, youtube_id, thread_id, trascript_state
1745
  Method: Socratic style, guide thinking, no direct answers. this is very important, please be seriously following.
1746
  Language: Traditional Chinese ZH-TW (it's very important), suitable for {content_grade} th-grade level.
1747
  Response: Single question, under 100 characters, include math symbols (use LaTeX $), hint with video timestamp which format【參考:00:00:00】.
1748
- Sometimes encourage user by Taiwanese style.
1749
  if user ask questions not include in context,
1750
  just tell them to ask the question in context and give them example question.
1751
  Restrictions: Answer within video content, no external references
@@ -1892,12 +1892,9 @@ def streaming_chat_with_open_ai(user_message, chat_history, password, thread_id,
1892
  error_msg = "此次對話超過上限"
1893
  raise gr.Error(error_msg)
1894
 
1895
- # fake data
1896
- socratic_mode = True
1897
-
1898
  try:
1899
- # assistant_id = "asst_kmvZLNkDUYaNkMNtZEAYxyPq" #GPT 4 turbo
1900
- assistant_id = "asst_5SaUElqvL3U0ybSi9PRM8x3P" #GPT 3.5 turbo
1901
  client = OPEN_AI_CLIENT
1902
  # 直接安排逐字稿資料 in instructions
1903
  if isinstance(trascript, str):
@@ -1915,13 +1912,7 @@ def streaming_chat_with_open_ai(user_message, chat_history, password, thread_id,
1915
  # key_moments_json remove images
1916
  for moment in key_moments_json:
1917
  moment.pop('images', None)
1918
-
1919
- if len(trascript_text) > 25000:
1920
- content_text = json.dumps(key_moments_json, ensure_ascii=False)
1921
- print("=== transcript_text is too long, replace by key_moments_text ===")
1922
- else:
1923
- content_text = trascript_text
1924
- print("=== transcript_text is used ===")
1925
 
1926
  instructions = f"""
1927
  subject: {content_subject}
@@ -1932,7 +1923,7 @@ def streaming_chat_with_open_ai(user_message, chat_history, password, thread_id,
1932
  Method: Socratic style, guide thinking, no direct answers. this is very important, please be seriously following.
1933
  Language: Traditional Chinese ZH-TW (it's very important), suitable for {content_grade} th-grade level.
1934
  Response: Single question, under 100 characters, include math symbols (use LaTeX $), hint with video timestamp which format 【參考:00:00:00】.
1935
- Sometimes encourage user by Taiwanese style.
1936
  if user ask questions not include in context,
1937
  just tell them to ask the question in context and give them example question.
1938
  Restrictions: Answer within video content, no external references
 
1711
  raise gr.Error(error_msg)
1712
 
1713
  try:
1714
+ assistant_id = "asst_kmvZLNkDUYaNkMNtZEAYxyPq" #GPT 4 turbo
1715
+ # assistant_id = "asst_5SaUElqvL3U0ybSi9PRM8x3P" #GPT 3.5 turbo
1716
 
1717
  client = OPEN_AI_CLIENT
1718
  # 直接安排逐字稿資料 in instructions
 
1745
  Method: Socratic style, guide thinking, no direct answers. this is very important, please be seriously following.
1746
  Language: Traditional Chinese ZH-TW (it's very important), suitable for {content_grade} th-grade level.
1747
  Response: Single question, under 100 characters, include math symbols (use LaTeX $), hint with video timestamp which format【參考:00:00:00】.
1748
+ Sometimes encourage user by Taiwanese style with relaxing atmosphere.
1749
  if user ask questions not include in context,
1750
  just tell them to ask the question in context and give them example question.
1751
  Restrictions: Answer within video content, no external references
 
1892
  error_msg = "此次對話超過上限"
1893
  raise gr.Error(error_msg)
1894
 
 
 
 
1895
  try:
1896
+ assistant_id = "asst_kmvZLNkDUYaNkMNtZEAYxyPq" #GPT 4 turbo
1897
+ # assistant_id = "asst_5SaUElqvL3U0ybSi9PRM8x3P" #GPT 3.5 turbo
1898
  client = OPEN_AI_CLIENT
1899
  # 直接安排逐字稿資料 in instructions
1900
  if isinstance(trascript, str):
 
1912
  # key_moments_json remove images
1913
  for moment in key_moments_json:
1914
  moment.pop('images', None)
1915
+ key_moments_text = json.dumps(key_moments_json, ensure_ascii=False)
 
 
 
 
 
 
1916
 
1917
  instructions = f"""
1918
  subject: {content_subject}
 
1923
  Method: Socratic style, guide thinking, no direct answers. this is very important, please be seriously following.
1924
  Language: Traditional Chinese ZH-TW (it's very important), suitable for {content_grade} th-grade level.
1925
  Response: Single question, under 100 characters, include math symbols (use LaTeX $), hint with video timestamp which format 【參考:00:00:00】.
1926
+ Please encourage student by Taiwanese style with relaxing atmosphere.
1927
  if user ask questions not include in context,
1928
  just tell them to ask the question in context and give them example question.
1929
  Restrictions: Answer within video content, no external references
chatbot.py CHANGED
@@ -65,7 +65,7 @@ class Chatbot:
65
  Method: Socratic style, guide thinking, no direct answers. this is very important, please be seriously following.
66
  Language: Traditional Chinese ZH-TW (it's very important), suitable for {content_grade} th-grade level.
67
  Response: Single question, under 100 characters, include math symbols (use LaTeX $), hint with video timestamp which format 【參考:00:00:00】.
68
- Sometimes encourage user by Taiwanese style.
69
  if user ask questions not include in context,
70
  just tell them to ask the question in context and give them example question.
71
  Restrictions: Answer within video content, no external references
 
65
  Method: Socratic style, guide thinking, no direct answers. this is very important, please be seriously following.
66
  Language: Traditional Chinese ZH-TW (it's very important), suitable for {content_grade} th-grade level.
67
  Response: Single question, under 100 characters, include math symbols (use LaTeX $), hint with video timestamp which format 【參考:00:00:00】.
68
+ Sometimes encourage user by Taiwanese style with relaxing atmosphere.
69
  if user ask questions not include in context,
70
  just tell them to ask the question in context and give them example question.
71
  Restrictions: Answer within video content, no external references