youngtsai commited on
Commit
9774a8c
·
1 Parent(s): 3a57f39

def setup_question_button_click(button, question_btn, chatbot, chat_func):

Browse files
Files changed (1) hide show
  1. app.py +17 -24
app.py CHANGED
@@ -854,7 +854,7 @@ def get_video_id_summary(video_id, df_string, source):
854
  else:
855
  # summary已存在,下载内容
856
  print("summary已存在于GCS中")
857
- summary_text = GCS_SERVICE.download_as_string(bucket_name, blob_name)
858
  summary_json = json.loads(summary_text)
859
 
860
  elif source == "drive":
@@ -2950,31 +2950,24 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
2950
  outputs=[msg]
2951
  )
2952
  # OPENAI ASSISTANT CHATBOT 連接按鈕點擊事件
2953
- btn_1_chat_with_opan_ai_assistant_input =[password, video_id, user_data, thread_id, trascript_state, key_moments, btn_1, chatbot, content_subject, content_grade, questions_answers_json, ai_chatbot_socratic_mode_btn]
2954
- btn_2_chat_with_opan_ai_assistant_input =[password, video_id, user_data, thread_id, trascript_state, key_moments, btn_2, chatbot, content_subject, content_grade, questions_answers_json, ai_chatbot_socratic_mode_btn]
2955
- btn_3_chat_with_opan_ai_assistant_input =[password, video_id, user_data, thread_id, trascript_state, key_moments, btn_3, chatbot, content_subject, content_grade, questions_answers_json, ai_chatbot_socratic_mode_btn]
2956
- btn_1.click(
2957
- chat_with_opan_ai_assistant,
2958
- inputs=btn_1_chat_with_opan_ai_assistant_input,
2959
- outputs=[msg, chatbot, thread_id],
2960
- scroll_to_output=True
2961
- )
2962
- btn_2.click(
2963
- chat_with_opan_ai_assistant,
2964
- inputs=btn_2_chat_with_opan_ai_assistant_input,
2965
- outputs=[msg, chatbot, thread_id],
2966
- scroll_to_output=True
2967
- )
2968
- btn_3.click(
2969
- chat_with_opan_ai_assistant,
2970
- inputs=btn_3_chat_with_opan_ai_assistant_input,
2971
- outputs=[msg, chatbot, thread_id],
2972
- scroll_to_output=True
2973
- )
2974
  btn_create_question.click(
2975
  change_questions,
2976
- inputs = [password, df_string_output],
2977
- outputs = [btn_1, btn_2, btn_3]
2978
  )
2979
 
2980
  # 其他精靈 ai_chatbot 模式
 
854
  else:
855
  # summary已存在,下载内容
856
  print("summary已存在于GCS中")
857
+ summary_text = GCS_SERVICE.download_as_string(bucket_name, summary_file_blob_name)
858
  summary_json = json.loads(summary_text)
859
 
860
  elif source == "drive":
 
2950
  outputs=[msg]
2951
  )
2952
  # OPENAI ASSISTANT CHATBOT 連接按鈕點擊事件
2953
+ def setup_question_button_click(button, question_btn, chatbot, chat_func):
2954
+ inputs = [password, video_id, user_data, thread_id, trascript_state, key_moments, question_btn, chatbot, content_subject, content_grade, questions_answers_json, ai_chatbot_socratic_mode_btn]
2955
+ outputs = [msg, chatbot, thread_id]
2956
+ button.click(
2957
+ chat_func,
2958
+ inputs=inputs,
2959
+ outputs=outputs,
2960
+ scroll_to_output=True
2961
+ )
2962
+ buttons = [btn_1, btn_2, btn_3]
2963
+ for button in buttons:
2964
+ setup_question_button_click(button, button, chatbot, chat_with_opan_ai_assistant)
2965
+
2966
+ # 為生成問題按鈕設定特殊的點擊事件
 
 
 
 
 
 
 
2967
  btn_create_question.click(
2968
  change_questions,
2969
+ inputs=[password, df_string_output],
2970
+ outputs=buttons
2971
  )
2972
 
2973
  # 其他精靈 ai_chatbot 模式