youngtsai commited on
Commit
0ee794c
·
1 Parent(s): 269bb11

displayDiv.style.display = 'none';

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -2623,6 +2623,28 @@ HEAD = """
2623
  }
2624
  }
2625
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2626
  """
2627
 
2628
  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:
@@ -2641,7 +2663,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
2641
  key_moments_state = gr.State() # 使用 gr.State 存储 key_moments
2642
  streaming_chat_thread_id_state = gr.State() # 使用 gr.State 存储 streaming_chat_thread_id
2643
  with gr.Tab("AI小精靈"):
2644
- with gr.Accordion("選擇 AI 小精靈") as chatbot_select_accordion:
2645
  with gr.Row():
2646
  user_avatar = "https://em-content.zobj.net/source/google/263/flushed-face_1f633.png"
2647
  ai_chatbot_bot_avatar = "https://junyitopicimg.s3.amazonaws.com/s4byy--icon.jpe?v=20200513013523726"
@@ -2683,7 +2705,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
2683
  """
2684
  foxcat_chatbot_name = gr.State("foxcat")
2685
  gr.Image(value=foxcat_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
2686
- foxcat_chatbot_select_btn = gr.Button("👆選擇【狐狸貓】", visible=True, variant="primary")
2687
  foxcat_chatbot_description_value = gr.Markdown(value=foxcat_chatbot_description, visible=True)
2688
  # 梨梨
2689
  with gr.Column(scale=1, variant="panel"):
@@ -2698,7 +2720,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
2698
  """
2699
  lili_chatbot_name = gr.State("lili")
2700
  gr.Image(value=lili_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
2701
- lili_chatbot_select_btn = gr.Button("👆選擇【梨梨】", visible=True, variant="primary")
2702
  lili_chatbot_description_value = gr.Markdown(value=lili_chatbot_description, visible=True)
2703
  # 麥麥
2704
  with gr.Column(scale=1, variant="panel"):
@@ -2713,7 +2735,7 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
2713
  """
2714
  maimai_chatbot_name = gr.State("maimai")
2715
  gr.Image(value=maimai_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
2716
- maimai_chatbot_select_btn = gr.Button("👆選擇【麥麥】", visible=True, variant="primary")
2717
  maimai_chatbot_description_value = gr.Markdown(value=maimai_chatbot_description, visible=True)
2718
 
2719
  with gr.Row("飛特精靈") as chatbot_open_ai:
 
2623
  }
2624
  }
2625
  </script>
2626
+
2627
+ <script>
2628
+ var selectButtons = document.querySelectorAll('.chatbot_select_btn');
2629
+
2630
+ // 为每个按钮添加点击事件监听器
2631
+ selectButtons.forEach(function(button) {
2632
+ button.addEventListener('click', function() {
2633
+ // 获取 #chatbot_select_accordion 下的第一个 button 元素
2634
+ var firstButton = document.querySelector('#chatbot_select_accordion button');
2635
+ var displayDiv = document.querySelector('#chatbot_select_accordion div:nth-child(3)');
2636
+ // 检查这个按钮是否存在
2637
+ if (firstButton) {
2638
+ // 移除 'open' 类
2639
+ firstButton.classList.remove('open');
2640
+ }
2641
+ if (displayDiv) {
2642
+ // display none
2643
+ displayDiv.style.display = 'none';
2644
+ }
2645
+ });
2646
+ });
2647
+ </script>
2648
  """
2649
 
2650
  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:
 
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"
2669
  ai_chatbot_bot_avatar = "https://junyitopicimg.s3.amazonaws.com/s4byy--icon.jpe?v=20200513013523726"
 
2705
  """
2706
  foxcat_chatbot_name = gr.State("foxcat")
2707
  gr.Image(value=foxcat_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
2708
+ foxcat_chatbot_select_btn = gr.Button("👆選擇【狐狸貓】", visible=True, variant="primary", elem_classes="chatbot_select_btn")
2709
  foxcat_chatbot_description_value = gr.Markdown(value=foxcat_chatbot_description, visible=True)
2710
  # 梨梨
2711
  with gr.Column(scale=1, variant="panel"):
 
2720
  """
2721
  lili_chatbot_name = gr.State("lili")
2722
  gr.Image(value=lili_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
2723
+ lili_chatbot_select_btn = gr.Button("👆選擇【梨梨】", visible=True, variant="primary", elem_classes="chatbot_select_btn")
2724
  lili_chatbot_description_value = gr.Markdown(value=lili_chatbot_description, visible=True)
2725
  # 麥麥
2726
  with gr.Column(scale=1, variant="panel"):
 
2735
  """
2736
  maimai_chatbot_name = gr.State("maimai")
2737
  gr.Image(value=maimai_chatbot_avatar_url, height=100, width=100, show_label=False, show_download_button=False)
2738
+ maimai_chatbot_select_btn = gr.Button("👆選擇【麥麥】", visible=True, variant="primary", elem_classes="chatbot_select_btn")
2739
  maimai_chatbot_description_value = gr.Markdown(value=maimai_chatbot_description, visible=True)
2740
 
2741
  with gr.Row("飛特精靈") as chatbot_open_ai: