Spaces:
Running
Running
# ALL CHATBOT SELECT LIST
Browse files
app.py
CHANGED
|
@@ -2434,7 +2434,8 @@ def create_thread_id():
|
|
| 2434 |
return thread_id
|
| 2435 |
|
| 2436 |
def chatbot_select(chatbot_name):
|
| 2437 |
-
chatbot_select_accordion_visible = gr.update(
|
|
|
|
| 2438 |
chatbot_open_ai_visible = gr.update(visible=False)
|
| 2439 |
chatbot_open_ai_streaming_visible = gr.update(visible=False)
|
| 2440 |
chatbot_jutor_visible = gr.update(visible=False)
|
|
@@ -2448,7 +2449,7 @@ def chatbot_select(chatbot_name):
|
|
| 2448 |
chatbot_jutor_visible = gr.update(visible=True)
|
| 2449 |
ai_name_update = gr.update(value=chatbot_name)
|
| 2450 |
|
| 2451 |
-
return chatbot_select_accordion_visible, chatbot_open_ai_visible, chatbot_open_ai_streaming_visible, chatbot_jutor_visible, ai_name_update
|
| 2452 |
|
| 2453 |
def update_avatar_images(avatar_images, maimai_chatbot_description_value):
|
| 2454 |
value = [[
|
|
@@ -2458,6 +2459,11 @@ def update_avatar_images(avatar_images, maimai_chatbot_description_value):
|
|
| 2458 |
ai_chatbot_update = gr.update(avatar_images=avatar_images, value=value)
|
| 2459 |
return ai_chatbot_update
|
| 2460 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2461 |
# --- Slide mode ---
|
| 2462 |
def update_slide(direction):
|
| 2463 |
global TRANSCRIPTS
|
|
@@ -2663,6 +2669,8 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
| 2663 |
key_moments_state = gr.State() # 使用 gr.State 存储 key_moments
|
| 2664 |
streaming_chat_thread_id_state = gr.State() # 使用 gr.State 存储 streaming_chat_thread_id
|
| 2665 |
with gr.Tab("AI小精靈"):
|
|
|
|
|
|
|
| 2666 |
with gr.Accordion("選擇 AI 小精靈", elem_id="chatbot_select_accordion") as chatbot_select_accordion:
|
| 2667 |
with gr.Row():
|
| 2668 |
user_avatar = "https://em-content.zobj.net/source/google/263/flushed-face_1f633.png"
|
|
@@ -3003,16 +3011,18 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
| 3003 |
mind_map_html = gr.HTML()
|
| 3004 |
|
| 3005 |
# --- Event ---
|
| 3006 |
-
|
|
|
|
|
|
|
| 3007 |
chatbot_open_ai_select_btn.click(
|
| 3008 |
chatbot_select,
|
| 3009 |
inputs=[chatbot_open_ai_name],
|
| 3010 |
-
outputs=
|
| 3011 |
)
|
| 3012 |
chatbot_open_ai_streaming_select_btn.click(
|
| 3013 |
chatbot_select,
|
| 3014 |
inputs=[chatbot_open_ai_streaming_name],
|
| 3015 |
-
outputs=
|
| 3016 |
).then(
|
| 3017 |
create_thread_id,
|
| 3018 |
inputs=[],
|
|
@@ -3021,7 +3031,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
| 3021 |
foxcat_chatbot_select_btn.click(
|
| 3022 |
chatbot_select,
|
| 3023 |
inputs=[foxcat_chatbot_name],
|
| 3024 |
-
outputs=
|
| 3025 |
).then(
|
| 3026 |
update_avatar_images,
|
| 3027 |
inputs=[foxcat_avatar_images, foxcat_chatbot_description_value],
|
|
@@ -3031,7 +3041,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
| 3031 |
lili_chatbot_select_btn.click(
|
| 3032 |
chatbot_select,
|
| 3033 |
inputs=[lili_chatbot_name],
|
| 3034 |
-
outputs=
|
| 3035 |
).then(
|
| 3036 |
update_avatar_images,
|
| 3037 |
inputs=[lili_avatar_images, lili_chatbot_description_value],
|
|
@@ -3041,13 +3051,19 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
| 3041 |
maimai_chatbot_select_btn.click(
|
| 3042 |
chatbot_select,
|
| 3043 |
inputs=[maimai_chatbot_name],
|
| 3044 |
-
outputs=
|
| 3045 |
).then(
|
| 3046 |
update_avatar_images,
|
| 3047 |
inputs=[maimai_avatar_images, maimai_chatbot_description_value],
|
| 3048 |
outputs=[ai_chatbot],
|
| 3049 |
scroll_to_output=True
|
| 3050 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3051 |
|
| 3052 |
# OPENAI ASSISTANT CHATBOT 模式
|
| 3053 |
send_button.click(
|
|
|
|
| 2434 |
return thread_id
|
| 2435 |
|
| 2436 |
def chatbot_select(chatbot_name):
|
| 2437 |
+
chatbot_select_accordion_visible = gr.update(visible=False)
|
| 2438 |
+
all_chatbot_select_btn_visible = gr.update(visible=True)
|
| 2439 |
chatbot_open_ai_visible = gr.update(visible=False)
|
| 2440 |
chatbot_open_ai_streaming_visible = gr.update(visible=False)
|
| 2441 |
chatbot_jutor_visible = gr.update(visible=False)
|
|
|
|
| 2449 |
chatbot_jutor_visible = gr.update(visible=True)
|
| 2450 |
ai_name_update = gr.update(value=chatbot_name)
|
| 2451 |
|
| 2452 |
+
return chatbot_select_accordion_visible, all_chatbot_select_btn_visible, chatbot_open_ai_visible, chatbot_open_ai_streaming_visible, chatbot_jutor_visible, ai_name_update
|
| 2453 |
|
| 2454 |
def update_avatar_images(avatar_images, maimai_chatbot_description_value):
|
| 2455 |
value = [[
|
|
|
|
| 2459 |
ai_chatbot_update = gr.update(avatar_images=avatar_images, value=value)
|
| 2460 |
return ai_chatbot_update
|
| 2461 |
|
| 2462 |
+
def show_all_chatbot_accordion():
|
| 2463 |
+
chatbot_select_accordion_visible = gr.update(visible=True)
|
| 2464 |
+
all_chatbot_select_btn_visible = gr.update(visible=False)
|
| 2465 |
+
return chatbot_select_accordion_visible, all_chatbot_select_btn_visible
|
| 2466 |
+
|
| 2467 |
# --- Slide mode ---
|
| 2468 |
def update_slide(direction):
|
| 2469 |
global TRANSCRIPTS
|
|
|
|
| 2669 |
key_moments_state = gr.State() # 使用 gr.State 存储 key_moments
|
| 2670 |
streaming_chat_thread_id_state = gr.State() # 使用 gr.State 存储 streaming_chat_thread_id
|
| 2671 |
with gr.Tab("AI小精靈"):
|
| 2672 |
+
with gr.Row():
|
| 2673 |
+
all_chatbot_select_btn = gr.Button("選擇 AI 小精靈 👈", elem_id="all_chatbot_select_btn", visible=False, variant="secondary", size="sm")
|
| 2674 |
with gr.Accordion("選擇 AI 小精靈", elem_id="chatbot_select_accordion") as chatbot_select_accordion:
|
| 2675 |
with gr.Row():
|
| 2676 |
user_avatar = "https://em-content.zobj.net/source/google/263/flushed-face_1f633.png"
|
|
|
|
| 3011 |
mind_map_html = gr.HTML()
|
| 3012 |
|
| 3013 |
# --- Event ---
|
| 3014 |
+
chatbot_select_outputs=[chatbot_select_accordion, all_chatbot_select_btn, chatbot_open_ai, chatbot_open_ai_streaming, chatbot_jutor, ai_name]
|
| 3015 |
+
|
| 3016 |
+
# OPEN AI CHATBOT SELECT
|
| 3017 |
chatbot_open_ai_select_btn.click(
|
| 3018 |
chatbot_select,
|
| 3019 |
inputs=[chatbot_open_ai_name],
|
| 3020 |
+
outputs=chatbot_select_outputs
|
| 3021 |
)
|
| 3022 |
chatbot_open_ai_streaming_select_btn.click(
|
| 3023 |
chatbot_select,
|
| 3024 |
inputs=[chatbot_open_ai_streaming_name],
|
| 3025 |
+
outputs=chatbot_select_outputs
|
| 3026 |
).then(
|
| 3027 |
create_thread_id,
|
| 3028 |
inputs=[],
|
|
|
|
| 3031 |
foxcat_chatbot_select_btn.click(
|
| 3032 |
chatbot_select,
|
| 3033 |
inputs=[foxcat_chatbot_name],
|
| 3034 |
+
outputs=chatbot_select_outputs
|
| 3035 |
).then(
|
| 3036 |
update_avatar_images,
|
| 3037 |
inputs=[foxcat_avatar_images, foxcat_chatbot_description_value],
|
|
|
|
| 3041 |
lili_chatbot_select_btn.click(
|
| 3042 |
chatbot_select,
|
| 3043 |
inputs=[lili_chatbot_name],
|
| 3044 |
+
outputs=chatbot_select_outputs
|
| 3045 |
).then(
|
| 3046 |
update_avatar_images,
|
| 3047 |
inputs=[lili_avatar_images, lili_chatbot_description_value],
|
|
|
|
| 3051 |
maimai_chatbot_select_btn.click(
|
| 3052 |
chatbot_select,
|
| 3053 |
inputs=[maimai_chatbot_name],
|
| 3054 |
+
outputs=chatbot_select_outputs
|
| 3055 |
).then(
|
| 3056 |
update_avatar_images,
|
| 3057 |
inputs=[maimai_avatar_images, maimai_chatbot_description_value],
|
| 3058 |
outputs=[ai_chatbot],
|
| 3059 |
scroll_to_output=True
|
| 3060 |
)
|
| 3061 |
+
# ALL CHATBOT SELECT LIST
|
| 3062 |
+
all_chatbot_select_btn.click(
|
| 3063 |
+
show_all_chatbot_accordion,
|
| 3064 |
+
inputs=[],
|
| 3065 |
+
outputs=[chatbot_select_accordion, all_chatbot_select_btn]
|
| 3066 |
+
)
|
| 3067 |
|
| 3068 |
# OPENAI ASSISTANT CHATBOT 模式
|
| 3069 |
send_button.click(
|