Spaces:
Running
Running
instructions
Browse files- app.py +25 -50
- chatbot.py +7 -7
app.py
CHANGED
@@ -1735,36 +1735,20 @@ def chat_with_opan_ai_assistant(password, youtube_id, thread_id, trascript_state
|
|
1735 |
moment.pop('end', None)
|
1736 |
moment.pop('text', None)
|
1737 |
key_moments_text = json.dumps(key_moments_json, ensure_ascii=False)
|
1738 |
-
|
1739 |
-
if len(trascript_text) > 25000:
|
1740 |
-
content_text = key_moments_text
|
1741 |
-
print("=== transcript_text is too long, replace by key_moments_text ===")
|
1742 |
-
else:
|
1743 |
-
content_text = trascript_text
|
1744 |
-
print("=== transcript_text is used ===")
|
1745 |
-
|
1746 |
instructions = f"""
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
- 請一定要用繁體中文回答 zh-TW,並用台灣人的口語表達,回答時不用特別說明這是台灣人的語氣,也不用說這是「台語的說法」
|
1760 |
-
- 請用 {content_grade} 的學生能懂的方式回答,不用提到「逐字稿」這個詞
|
1761 |
-
- 如果學生問了一些問題你無法判斷,請告訴學生你無法判斷,並建議學生可以問其他問題
|
1762 |
-
- 或者你可以反問學生一些問題,幫助學生更好的理解資料,字數在100字以內
|
1763 |
-
- 如果學生的問題與資料文本無關,請告訴學生你「無法回答超出影片範圍的問題」,並告訴他可以怎麼問什麼樣的問題(一個就好)
|
1764 |
-
- 回答範圍一定要在逐字稿資料內,不要引用其他資料,請嚴格執行
|
1765 |
-
- 並在重複問句後給予學生鼓勵,讓學生有學習的動力
|
1766 |
-
- 回答時數學式請用數學符號代替文字(Latex 用 $ 字號 render)
|
1767 |
-
- 只要是參考逐字稿資料,please use the timestamp format, example:【參考資料:00:00:00】
|
1768 |
"""
|
1769 |
|
1770 |
print("=== instructions ===")
|
@@ -1940,27 +1924,18 @@ def streaming_chat_with_open_ai(user_message, chat_history, password, thread_id,
|
|
1940 |
print("=== transcript_text is used ===")
|
1941 |
|
1942 |
instructions = f"""
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
- 請一定要用繁體中文回答 zh-TW,並用台灣人的口語表達,回答時不用特別說明這是台灣人的語氣,也不用說這是「台語的說法」
|
1956 |
-
- 請用 {content_grade} 的學生能懂的方式回答,不用提到「逐字稿」這個詞
|
1957 |
-
- 如果學生問了一些問題你無法判斷,請告訴學生你無法判斷,並建議學生可以問其他問題
|
1958 |
-
- 或者你可以反問學生一些問題,幫助學生更好的理解資料,字數在100字以內
|
1959 |
-
- 如果學生的問題與資料文本無關,請告訴學生你「無法回答超出影片範圍的問題」,並告訴他可以怎麼問什麼樣的問題(一個就好)
|
1960 |
-
- 回答範圍一定要在逐字稿資料內,不要引用其他資料,請嚴格執行
|
1961 |
-
- 並在重複問句後給予學生鼓勵,讓學生有學習的動力
|
1962 |
-
- 回答時數學式請用數學符號代替文字(Latex 用 $ 字號 render)
|
1963 |
-
- 只要是參考逐字稿資料,please use the timestamp format, example:【參考資料:00:00:00】
|
1964 |
"""
|
1965 |
|
1966 |
# 创建线程
|
|
|
1735 |
moment.pop('end', None)
|
1736 |
moment.pop('text', None)
|
1737 |
key_moments_text = json.dumps(key_moments_json, ensure_ascii=False)
|
1738 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1739 |
instructions = f"""
|
1740 |
+
subject: {content_subject}
|
1741 |
+
grade: {content_grade}
|
1742 |
+
context: {key_moments_text}
|
1743 |
+
Assistant Role: you are a {content_subject} teacher
|
1744 |
+
User Role: {content_grade} th-grade student.
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1752 |
"""
|
1753 |
|
1754 |
print("=== instructions ===")
|
|
|
1924 |
print("=== transcript_text is used ===")
|
1925 |
|
1926 |
instructions = f"""
|
1927 |
+
subject: {content_subject}
|
1928 |
+
grade: {content_grade}
|
1929 |
+
context: {key_moments_text}
|
1930 |
+
Assistant Role: you are a {content_subject} teacher
|
1931 |
+
User Role: {content_grade} th-grade student.
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1939 |
"""
|
1940 |
|
1941 |
# 创建线程
|
chatbot.py
CHANGED
@@ -60,13 +60,13 @@ class Chatbot:
|
|
60 |
subject: {content_subject}
|
61 |
grade: {content_grade}
|
62 |
context: {key_moments_text}
|
63 |
-
|
64 |
-
Role: {
|
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
|
68 |
-
Sometimes encourage user by Taiwanese
|
69 |
-
if user ask questions not include in
|
70 |
just tell them to ask the question in context and give them example question.
|
71 |
Restrictions: Answer within video content, no external references
|
72 |
"""
|
@@ -109,8 +109,8 @@ class Chatbot:
|
|
109 |
"Content-Type": "application/json",
|
110 |
"x-api-key": self.jutor_chat_key,
|
111 |
}
|
112 |
-
|
113 |
-
model = "gpt-3.5-turbo-0125"
|
114 |
data = {
|
115 |
"data": {
|
116 |
"messages": messages,
|
|
|
60 |
subject: {content_subject}
|
61 |
grade: {content_grade}
|
62 |
context: {key_moments_text}
|
63 |
+
Assistant Role: you are a {content_subject} teacher
|
64 |
+
User Role: {content_grade} th-grade student.
|
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
|
72 |
"""
|
|
|
109 |
"Content-Type": "application/json",
|
110 |
"x-api-key": self.jutor_chat_key,
|
111 |
}
|
112 |
+
model = "gpt-4-1106-preview"
|
113 |
+
# model = "gpt-3.5-turbo-0125"
|
114 |
data = {
|
115 |
"data": {
|
116 |
"messages": messages,
|