Spaces:
Sleeping
Sleeping
file_list = client.beta.assistants.files.list(assistant_id=assistant_id)
Browse files
app.py
CHANGED
@@ -997,10 +997,27 @@ def respond(user_message, data, chat_history, socratic_mode=False):
|
|
997 |
def chat_with_youtube_transcript(youtube_id, thread_id, user_message, chat_history, socratic_mode=False):
|
998 |
assistant_id = "asst_kmvZLNkDUYaNkMNtZEAYxyPq"
|
999 |
client = OPEN_AI_CLIENT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1000 |
instructions = f"""
|
1001 |
你是一個擅長資料分析跟影片教學的老師,user 為學生
|
1002 |
請根據 assistant beta 的上傳資料
|
1003 |
-
|
1004 |
如果沒有資料,請告訴用戶沒有逐字稿資料,但仍然可以進行對話,使用台灣人的口與表達,及繁體中文 zh-TW
|
1005 |
請嚴格執行,只根據 youtube_id = {youtube_id} 為資料文本,沒有就是沒有資料,不要引用其他資料
|
1006 |
|
@@ -1019,6 +1036,7 @@ def chat_with_youtube_transcript(youtube_id, thread_id, user_message, chat_histo
|
|
1019 |
如果學生的問題與資料文本無關,請告訴學生你無法回答超出範圍的問題
|
1020 |
最後只要是參考逐字稿資料,請在回答的最後標註【參考資料:時間軸位置?(分):?(秒)】
|
1021 |
"""
|
|
|
1022 |
# 创建线程
|
1023 |
if not thread_id:
|
1024 |
thread = client.beta.threads.create()
|
|
|
997 |
def chat_with_youtube_transcript(youtube_id, thread_id, user_message, chat_history, socratic_mode=False):
|
998 |
assistant_id = "asst_kmvZLNkDUYaNkMNtZEAYxyPq"
|
999 |
client = OPEN_AI_CLIENT
|
1000 |
+
# 根據 youtube_id 找到 file_id
|
1001 |
+
file_list = client.beta.assistants.files.list(assistant_id=assistant_id)
|
1002 |
+
if len(file_list.data) > 0:
|
1003 |
+
for file in file_list.data:
|
1004 |
+
if file.name == f"{youtube_id}_transcript.txt":
|
1005 |
+
file_id = file.id
|
1006 |
+
break
|
1007 |
+
else:
|
1008 |
+
file_id = None
|
1009 |
+
else:
|
1010 |
+
file_id = None
|
1011 |
+
|
1012 |
+
print("===chat_with_youtube_transcript===")
|
1013 |
+
print(f"youtube_id: {youtube_id}")
|
1014 |
+
print(f"file_id: {file_id}")
|
1015 |
+
print("===chat_with_youtube_transcript===")
|
1016 |
+
|
1017 |
instructions = f"""
|
1018 |
你是一個擅長資料分析跟影片教學的老師,user 為學生
|
1019 |
請根據 assistant beta 的上傳資料
|
1020 |
+
如果 {file_id} 不為None,表示有找到 youtube_id = {youtube_id} 為資料文本,自行判斷資料的種類,
|
1021 |
如果沒有資料,請告訴用戶沒有逐字稿資料,但仍然可以進行對話,使用台灣人的口與表達,及繁體中文 zh-TW
|
1022 |
請嚴格執行,只根據 youtube_id = {youtube_id} 為資料文本,沒有就是沒有資料,不要引用其他資料
|
1023 |
|
|
|
1036 |
如果學生的問題與資料文本無關,請告訴學生你無法回答超出範圍的問題
|
1037 |
最後只要是參考逐字稿資料,請在回答的最後標註【參考資料:時間軸位置?(分):?(秒)】
|
1038 |
"""
|
1039 |
+
|
1040 |
# 创建线程
|
1041 |
if not thread_id:
|
1042 |
thread = client.beta.threads.create()
|