Spaces:
Running
Running
def setup_question_button_click(button, inputs_list, outputs_list, chat_func, scroll_to_output=True):
Browse files
app.py
CHANGED
@@ -2613,7 +2613,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
2613 |
with gr.Tab("AI小精靈"):
|
2614 |
with gr.Accordion("選擇 AI 小精靈", open=True) as chatbot_select_accordion:
|
2615 |
with gr.Row():
|
2616 |
-
with gr.Column(scale=1, variant="panel", visible=
|
2617 |
chatbot_avatar_url = "https://junyitopicimg.s3.amazonaws.com/s4byy--icon.jpe?v=20200513013523726"
|
2618 |
chatbot_description = """Hi,我是你的AI學伴【飛特精靈】,\n
|
2619 |
我可以陪你一起學習本次的內容,有什麼問題都可以問我喔!\n
|
@@ -2950,24 +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 |
-
def setup_question_button_click(button,
|
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 |
-
|
2958 |
-
|
2959 |
-
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
for
|
2964 |
-
|
|
|
|
|
2965 |
|
2966 |
# 為生成問題按鈕設定特殊的點擊事件
|
2967 |
btn_create_question.click(
|
2968 |
change_questions,
|
2969 |
inputs=[password, df_string_output],
|
2970 |
-
outputs=
|
2971 |
)
|
2972 |
|
2973 |
# 其他精靈 ai_chatbot 模式
|
@@ -2978,27 +2978,11 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
2978 |
scroll_to_output=True
|
2979 |
)
|
2980 |
# 其他精靈 ai_chatbot 连接按钮点击事件
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
chat_with_ai
|
2986 |
-
inputs=ai_chatbot_question_1_chat_with_ai_input,
|
2987 |
-
outputs=[ai_msg, ai_chatbot],
|
2988 |
-
scroll_to_output=True
|
2989 |
-
)
|
2990 |
-
ai_chatbot_question_2.click(
|
2991 |
-
chat_with_ai,
|
2992 |
-
inputs=ai_chatbot_question_2_chat_with_ai_input,
|
2993 |
-
outputs=[ai_msg, ai_chatbot],
|
2994 |
-
scroll_to_output=True
|
2995 |
-
)
|
2996 |
-
ai_chatbot_question_3.click(
|
2997 |
-
chat_with_ai,
|
2998 |
-
inputs=ai_chatbot_question_3_chat_with_ai_input,
|
2999 |
-
outputs=[ai_msg, ai_chatbot],
|
3000 |
-
scroll_to_output=True
|
3001 |
-
)
|
3002 |
|
3003 |
# file_upload.change(process_file, inputs=file_upload, outputs=df_string_output)
|
3004 |
# file_upload.change(process_file, inputs=file_upload, outputs=[btn_1, btn_2, btn_3, df_summarise, df_string_output])
|
|
|
2613 |
with gr.Tab("AI小精靈"):
|
2614 |
with gr.Accordion("選擇 AI 小精靈", open=True) as chatbot_select_accordion:
|
2615 |
with gr.Row():
|
2616 |
+
with gr.Column(scale=1, variant="panel", visible=True):
|
2617 |
chatbot_avatar_url = "https://junyitopicimg.s3.amazonaws.com/s4byy--icon.jpe?v=20200513013523726"
|
2618 |
chatbot_description = """Hi,我是你的AI學伴【飛特精靈】,\n
|
2619 |
我可以陪你一起學習本次的內容,有什麼問題都可以問我喔!\n
|
|
|
2950 |
outputs=[msg]
|
2951 |
)
|
2952 |
# OPENAI ASSISTANT CHATBOT 連接按鈕點擊事件
|
2953 |
+
def setup_question_button_click(button, inputs_list, outputs_list, chat_func, scroll_to_output=True):
|
|
|
|
|
2954 |
button.click(
|
2955 |
+
chat_func,
|
2956 |
+
inputs=inputs_list,
|
2957 |
+
outputs=outputs_list,
|
2958 |
+
scroll_to_output=scroll_to_output
|
2959 |
+
)
|
2960 |
+
question_buttons = [btn_1, btn_2, btn_3]
|
2961 |
+
for question_btn in question_buttons:
|
2962 |
+
inputs_list = [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]
|
2963 |
+
outputs_list = [msg, chatbot, thread_id]
|
2964 |
+
setup_question_button_click(question_btn, inputs_list, outputs_list, chat_with_opan_ai_assistant)
|
2965 |
|
2966 |
# 為生成問題按鈕設定特殊的點擊事件
|
2967 |
btn_create_question.click(
|
2968 |
change_questions,
|
2969 |
inputs=[password, df_string_output],
|
2970 |
+
outputs=question_buttons
|
2971 |
)
|
2972 |
|
2973 |
# 其他精靈 ai_chatbot 模式
|
|
|
2978 |
scroll_to_output=True
|
2979 |
)
|
2980 |
# 其他精靈 ai_chatbot 连接按钮点击事件
|
2981 |
+
ai_chatbot_buttons = [ai_chatbot_question_1, ai_chatbot_question_2, ai_chatbot_question_3]
|
2982 |
+
for ai_question_btn in ai_chatbot_buttons:
|
2983 |
+
inputs_list = [ai_name, password, video_id, user_data, trascript_state, key_moments, ai_question_btn, ai_chatbot, content_subject, content_grade, questions_answers_json, ai_chatbot_socratic_mode_btn]
|
2984 |
+
outputs_list = [ai_msg, ai_chatbot]
|
2985 |
+
setup_question_button_click(ai_question_btn, inputs_list, outputs_list, chat_with_ai)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2986 |
|
2987 |
# file_upload.change(process_file, inputs=file_upload, outputs=df_string_output)
|
2988 |
# file_upload.change(process_file, inputs=file_upload, outputs=[btn_1, btn_2, btn_3, df_summarise, df_string_output])
|