youngtsai commited on
Commit
cdaf4d8
1 Parent(s): c5051e3

video_id = gr.Textbox(label="video_id")

Browse files
Files changed (1) hide show
  1. app.py +21 -19
app.py CHANGED
@@ -532,17 +532,19 @@ def process_youtube_link(link):
532
  mind_map_html = get_mind_map_html(mind_map)
533
 
534
  # 确保返回与 UI 组件预期匹配的输出
535
- return questions[0] if len(questions) > 0 else "", \
536
- questions[1] if len(questions) > 1 else "", \
537
- questions[2] if len(questions) > 2 else "", \
538
- formatted_transcript_json, \
539
- summary, \
540
- mind_map, \
541
- mind_map_html, \
542
- html_content, \
543
- simple_html_content, \
544
- first_image, \
545
- first_text,
 
 
546
 
547
 
548
  def format_transcript_to_html(formatted_transcript):
@@ -774,7 +776,6 @@ def get_video_id_summary(video_id, df_string, source):
774
 
775
  return summary_json
776
 
777
-
778
  def generate_summarise(df_string):
779
  # 使用 OpenAI 生成基于上传数据的问题
780
  sys_content = "你是一個擅長資料分析跟影片教學的老師,user 為學生,請精讀資料文本,自行判斷資料的種類,使用 zh-TW"
@@ -823,7 +824,6 @@ def generate_summarise(df_string):
823
 
824
  return df_summarise
825
 
826
-
827
  def generate_questions(df_string):
828
  # 使用 OpenAI 生成基于上传数据的问题
829
 
@@ -1088,8 +1088,7 @@ def prev_slide():
1088
  def next_slide():
1089
  return update_slide(1)
1090
 
1091
- def get_video_id():
1092
- return VIDEO_ID
1093
 
1094
  HEAD = """
1095
  <meta charset="UTF-8">
@@ -1124,6 +1123,7 @@ with gr.Blocks() as demo:
1124
  with gr.Column(scale=2):
1125
  file_upload = gr.File(label="Upload your CSV or Word file", visible=False)
1126
  youtube_link = gr.Textbox(label="Enter YouTube Link")
 
1127
  youtube_link_btn = gr.Button("Submit_YouTube_Link")
1128
  web_link = gr.Textbox(label="Enter Web Page Link", visible=False)
1129
  chatbot = gr.Chatbot()
@@ -1176,23 +1176,23 @@ with gr.Blocks() as demo:
1176
  # chat_with_youtube_transcript
1177
  send_button.click(
1178
  chat_with_youtube_transcript,
1179
- inputs=[get_video_id, thread_id, msg, chatbot, socratic_mode_btn],
1180
  outputs=[msg, chatbot, thread_id]
1181
  )
1182
  # 连接按钮点击事件
1183
  btn_1.click(
1184
  chat_with_youtube_transcript,
1185
- inputs=[get_video_id, thread_id, btn_1, chatbot, socratic_mode_btn],
1186
  outputs=[msg, chatbot, thread_id]
1187
  )
1188
  btn_2.click(
1189
  chat_with_youtube_transcript,
1190
- inputs=[get_video_id, thread_id, btn_2, chatbot, socratic_mode_btn],
1191
  outputs=[msg, chatbot, thread_id]
1192
  )
1193
  btn_3.click(
1194
  chat_with_youtube_transcript,
1195
- inputs=[get_video_id, thread_id, btn_3, chatbot, socratic_mode_btn],
1196
  outputs=[msg, chatbot, thread_id]
1197
  )
1198
 
@@ -1206,6 +1206,7 @@ with gr.Blocks() as demo:
1206
  process_youtube_link,
1207
  inputs=youtube_link,
1208
  outputs=[
 
1209
  btn_1,
1210
  btn_2,
1211
  btn_3,
@@ -1224,6 +1225,7 @@ with gr.Blocks() as demo:
1224
  process_youtube_link,
1225
  inputs=youtube_link,
1226
  outputs=[
 
1227
  btn_1,
1228
  btn_2,
1229
  btn_3,
 
532
  mind_map_html = get_mind_map_html(mind_map)
533
 
534
  # 确保返回与 UI 组件预期匹配的输出
535
+ return video_id, \
536
+ questions[0] if len(questions) > 0 else "", \
537
+ questions[1] if len(questions) > 1 else "", \
538
+ questions[2] if len(questions) > 2 else "", \
539
+ formatted_transcript_json, \
540
+ summary, \
541
+ mind_map, \
542
+ mind_map_html, \
543
+ html_content, \
544
+ simple_html_content, \
545
+ first_image, \
546
+ first_text,
547
+
548
 
549
 
550
  def format_transcript_to_html(formatted_transcript):
 
776
 
777
  return summary_json
778
 
 
779
  def generate_summarise(df_string):
780
  # 使用 OpenAI 生成基于上传数据的问题
781
  sys_content = "你是一個擅長資料分析跟影片教學的老師,user 為學生,請精讀資料文本,自行判斷資料的種類,使用 zh-TW"
 
824
 
825
  return df_summarise
826
 
 
827
  def generate_questions(df_string):
828
  # 使用 OpenAI 生成基于上传数据的问题
829
 
 
1088
  def next_slide():
1089
  return update_slide(1)
1090
 
1091
+
 
1092
 
1093
  HEAD = """
1094
  <meta charset="UTF-8">
 
1123
  with gr.Column(scale=2):
1124
  file_upload = gr.File(label="Upload your CSV or Word file", visible=False)
1125
  youtube_link = gr.Textbox(label="Enter YouTube Link")
1126
+ video_id = gr.Textbox(label="video_id")
1127
  youtube_link_btn = gr.Button("Submit_YouTube_Link")
1128
  web_link = gr.Textbox(label="Enter Web Page Link", visible=False)
1129
  chatbot = gr.Chatbot()
 
1176
  # chat_with_youtube_transcript
1177
  send_button.click(
1178
  chat_with_youtube_transcript,
1179
+ inputs=[video_id, thread_id, msg, chatbot, socratic_mode_btn],
1180
  outputs=[msg, chatbot, thread_id]
1181
  )
1182
  # 连接按钮点击事件
1183
  btn_1.click(
1184
  chat_with_youtube_transcript,
1185
+ inputs=[video_id, thread_id, btn_1, chatbot, socratic_mode_btn],
1186
  outputs=[msg, chatbot, thread_id]
1187
  )
1188
  btn_2.click(
1189
  chat_with_youtube_transcript,
1190
+ inputs=[video_id, thread_id, btn_2, chatbot, socratic_mode_btn],
1191
  outputs=[msg, chatbot, thread_id]
1192
  )
1193
  btn_3.click(
1194
  chat_with_youtube_transcript,
1195
+ inputs=[video_id, thread_id, btn_3, chatbot, socratic_mode_btn],
1196
  outputs=[msg, chatbot, thread_id]
1197
  )
1198
 
 
1206
  process_youtube_link,
1207
  inputs=youtube_link,
1208
  outputs=[
1209
+ video_id,
1210
  btn_1,
1211
  btn_2,
1212
  btn_3,
 
1225
  process_youtube_link,
1226
  inputs=youtube_link,
1227
  outputs=[
1228
+ video_id,
1229
  btn_1,
1230
  btn_2,
1231
  btn_3,