Spaces:
Running
Running
# 飛特音速 add
Browse files
app.py
CHANGED
@@ -2960,7 +2960,6 @@ def init_params(text, request: gr.Request):
|
|
2960 |
is_env_prod = gr.update(value=False)
|
2961 |
|
2962 |
# if youtube_link in query_params
|
2963 |
-
# NOTE: 目前 process_youtube_link 是透過 youtube_link.input 觸發,所以這邊修改 youtube_link 的 value 時不會觸發 process_youtube_link
|
2964 |
if "youtube_id" in request.query_params:
|
2965 |
youtube_id = request.query_params["youtube_id"]
|
2966 |
youtube_link = f"https://www.youtube.com/watch?v={youtube_id}"
|
@@ -2978,7 +2977,7 @@ def init_params(text, request: gr.Request):
|
|
2978 |
lesson_plan_accordion = gr.update(visible=False)
|
2979 |
exit_ticket_accordion = gr.update(visible=False)
|
2980 |
ai_chatbot_params = gr.update(visible=False)
|
2981 |
-
|
2982 |
if IS_ENV_PROD == "True":
|
2983 |
is_env_prod = gr.update(value=True)
|
2984 |
|
@@ -3039,6 +3038,20 @@ HEAD = """
|
|
3039 |
</script>
|
3040 |
"""
|
3041 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3042 |
with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.amber, text_size = gr.themes.sizes.text_lg), head=HEAD) as demo:
|
3043 |
with gr.Row() as admin:
|
3044 |
password = gr.Textbox(label="Password", type="password", elem_id="password_input", visible=True)
|
@@ -3078,6 +3091,20 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
3078 |
latex_delimiters = [{"left": "$", "right": "$", "display": False}]
|
3079 |
with gr.Accordion("選擇 AI 小精靈", elem_id="chatbot_select_accordion") as chatbot_select_accordion:
|
3080 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3081 |
user_avatar = "https://em-content.zobj.net/source/google/263/flushed-face_1f633.png"
|
3082 |
# 飛特精靈
|
3083 |
with gr.Column(scale=1, variant="panel", visible=True):
|
@@ -3145,20 +3172,6 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
3145 |
maimai_chatbot_select_btn = gr.Button("👆選擇【麥麥】", visible=True, variant="primary", elem_classes="chatbot_select_btn")
|
3146 |
with gr.Accordion("💙 麥麥 敘述", open=False):
|
3147 |
maimai_chatbot_description_value = gr.Markdown(value=maimai_chatbot_description, visible=True)
|
3148 |
-
# 飛特音速
|
3149 |
-
with gr.Column(scale=1, variant="panel", visible=True):
|
3150 |
-
streaming_chatbot_avatar_url = "https://storage.googleapis.com/wpassets.junyiacademy.org/1/2020/11/1-%E6%98%9F%E7%A9%BA%E9%A0%AD%E8%B2%BC-%E5%A4%AA%E7%A9%BA%E7%8B%90%E7%8B%B8%E8%B2%93-150x150.png"
|
3151 |
-
streaming_chatbot_description = """Hi,我是【飛特音速】, \n
|
3152 |
-
說話比較快,但有什麼問題都可以問我喔! \n
|
3153 |
-
🚀 我沒有預設問題、也沒有語音輸入,適合快問快答,一起練習問出好問題吧 \n
|
3154 |
-
🔠 擅長用文字表達的你,可以用鍵盤輸入你的問題,我會盡力回答你的問題喔\n
|
3155 |
-
💤 我還在成長,體力���限,每一次學習只能回答十個問題,請讓我休息一下再問問題喔~
|
3156 |
-
"""
|
3157 |
-
chatbot_open_ai_streaming_name = gr.State("chatbot_open_ai_streaming")
|
3158 |
-
gr.Image(value=streaming_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
|
3159 |
-
chatbot_open_ai_streaming_select_btn = gr.Button("👆選擇【飛特音速】", elem_id="streaming_chatbot_btn", visible=True, variant="primary")
|
3160 |
-
with gr.Accordion("🚀 飛特音速 敘述", open=False):
|
3161 |
-
gr.Markdown(value=streaming_chatbot_description, visible=True)
|
3162 |
# 尚未開放
|
3163 |
with gr.Column(scale=1, variant="panel"):
|
3164 |
gr.Markdown(value="### 尚未開放", visible=True)
|
@@ -3174,6 +3187,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
3174 |
additional_inputs = [password, video_id, user_data, streaming_chat_thread_id_state, trascript_state, key_moments_state, content_subject_state, content_grade_state, ai_chatbot_socratic_mode_btn]
|
3175 |
streaming_chat = gr.ChatInterface(
|
3176 |
fn=chat_with_opan_ai_assistant_streaming,
|
|
|
3177 |
additional_inputs=additional_inputs,
|
3178 |
submit_btn="送出",
|
3179 |
retry_btn=None,
|
@@ -3929,4 +3943,4 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
3929 |
outputs = init_outputs
|
3930 |
)
|
3931 |
|
3932 |
-
demo.launch(allowed_paths=["videos"], server_name="0.0.0.0", server_port=7860)
|
|
|
2960 |
is_env_prod = gr.update(value=False)
|
2961 |
|
2962 |
# if youtube_link in query_params
|
|
|
2963 |
if "youtube_id" in request.query_params:
|
2964 |
youtube_id = request.query_params["youtube_id"]
|
2965 |
youtube_link = f"https://www.youtube.com/watch?v={youtube_id}"
|
|
|
2977 |
lesson_plan_accordion = gr.update(visible=False)
|
2978 |
exit_ticket_accordion = gr.update(visible=False)
|
2979 |
ai_chatbot_params = gr.update(visible=False)
|
2980 |
+
|
2981 |
if IS_ENV_PROD == "True":
|
2982 |
is_env_prod = gr.update(value=True)
|
2983 |
|
|
|
3038 |
</script>
|
3039 |
"""
|
3040 |
|
3041 |
+
streaming_chat_greeting = """
|
3042 |
+
Hi,我是【飛特音速】,說話比較快,但有什麼問題都可以問我喔! \n
|
3043 |
+
🚀 我沒有預設問題、也沒有語音輸入,適合快問快答的你 \n
|
3044 |
+
🔠 鍵盤輸入你的問題,我會盡力回答你的問題喔!\n
|
3045 |
+
💤 我還在成長,體力有限,每一次學習只能回答十個問題,請讓我休息一下再問問題喔!
|
3046 |
+
"""
|
3047 |
+
latex_delimiters = [{"left": "$", "right": "$", "display": False}]
|
3048 |
+
streaming_ai_chatbot = gr.Chatbot(
|
3049 |
+
show_share_button=False,
|
3050 |
+
likeable=True,
|
3051 |
+
latex_delimiters=latex_delimiters,
|
3052 |
+
show_copy_button=True,
|
3053 |
+
)
|
3054 |
+
|
3055 |
with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, secondary_hue=gr.themes.colors.amber, text_size = gr.themes.sizes.text_lg), head=HEAD) as demo:
|
3056 |
with gr.Row() as admin:
|
3057 |
password = gr.Textbox(label="Password", type="password", elem_id="password_input", visible=True)
|
|
|
3091 |
latex_delimiters = [{"left": "$", "right": "$", "display": False}]
|
3092 |
with gr.Accordion("選擇 AI 小精靈", elem_id="chatbot_select_accordion") as chatbot_select_accordion:
|
3093 |
with gr.Row():
|
3094 |
+
# 飛特音速
|
3095 |
+
with gr.Column(scale=1, variant="panel", visible=True):
|
3096 |
+
streaming_chatbot_avatar_url = "https://storage.googleapis.com/wpassets.junyiacademy.org/1/2020/11/1-%E6%98%9F%E7%A9%BA%E9%A0%AD%E8%B2%BC-%E5%A4%AA%E7%A9%BA%E7%8B%90%E7%8B%B8%E8%B2%93-150x150.png"
|
3097 |
+
streaming_chatbot_description = """Hi,我是【飛特音速】, \n
|
3098 |
+
說話比較快,但有什麼問題都可以問我喔! \n
|
3099 |
+
🚀 我沒有預設問題、也沒有語音輸入,適合快問快答,一起練習問出好問題吧 \n
|
3100 |
+
🔠 擅長用文字表達的你,可以用鍵盤輸入你的問題,我會盡力回答你的問題喔\n
|
3101 |
+
💤 我還在成長,體力有限,每一次學習只能回答十個問題,請讓我休息一下再問問題喔~
|
3102 |
+
"""
|
3103 |
+
chatbot_open_ai_streaming_name = gr.State("chatbot_open_ai_streaming")
|
3104 |
+
gr.Image(value=streaming_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
|
3105 |
+
chatbot_open_ai_streaming_select_btn = gr.Button("👆選擇【飛特音速】", elem_id="streaming_chatbot_btn", visible=True, variant="primary")
|
3106 |
+
with gr.Accordion("🚀 飛特音速 敘述", open=False):
|
3107 |
+
gr.Markdown(value=streaming_chatbot_description, visible=True)
|
3108 |
user_avatar = "https://em-content.zobj.net/source/google/263/flushed-face_1f633.png"
|
3109 |
# 飛特精靈
|
3110 |
with gr.Column(scale=1, variant="panel", visible=True):
|
|
|
3172 |
maimai_chatbot_select_btn = gr.Button("👆選擇【麥麥】", visible=True, variant="primary", elem_classes="chatbot_select_btn")
|
3173 |
with gr.Accordion("💙 麥麥 敘述", open=False):
|
3174 |
maimai_chatbot_description_value = gr.Markdown(value=maimai_chatbot_description, visible=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3175 |
# 尚未開放
|
3176 |
with gr.Column(scale=1, variant="panel"):
|
3177 |
gr.Markdown(value="### 尚未開放", visible=True)
|
|
|
3187 |
additional_inputs = [password, video_id, user_data, streaming_chat_thread_id_state, trascript_state, key_moments_state, content_subject_state, content_grade_state, ai_chatbot_socratic_mode_btn]
|
3188 |
streaming_chat = gr.ChatInterface(
|
3189 |
fn=chat_with_opan_ai_assistant_streaming,
|
3190 |
+
chatbot=streaming_ai_chatbot,
|
3191 |
additional_inputs=additional_inputs,
|
3192 |
submit_btn="送出",
|
3193 |
retry_btn=None,
|
|
|
3943 |
outputs = init_outputs
|
3944 |
)
|
3945 |
|
3946 |
+
demo.launch(allowed_paths=["videos"], server_name="0.0.0.0", server_port=7860, show_error=True)
|