youngtsai commited on
Commit
20111b1
·
verified ·
1 Parent(s): e501f08

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -33,16 +33,16 @@ def process_selected_files(selected_files, file_list):
33
  # 假資料模擬處理 RAG
34
  return f"已處理的文件: {', '.join(selected_paths)}"
35
 
36
- def toggle_visibility(current_state):
37
- return gr.update(visible=not current_state), not current_state
38
 
39
  with gr.Blocks() as demo:
40
  gr.Markdown("# AI Notes Assistant")
41
 
42
  with gr.Row():
43
- toggle_sources = gr.Button("顯示/隱藏 來源選單")
44
- toggle_chat = gr.Button("顯示/隱藏 對話區域")
45
- toggle_features = gr.Button("顯示/隱藏 功能卡片")
46
 
47
  with gr.Row():
48
  with gr.Column(visible=True) as source_column:
@@ -75,13 +75,9 @@ with gr.Blocks() as demo:
75
  with gr.Tab("其他功能"):
76
  gr.Markdown("此處可以添加更多功能卡片")
77
 
78
- source_visible = gr.State(True)
79
- chat_visible = gr.State(True)
80
- feature_visible = gr.State(True)
81
-
82
- toggle_sources.click(toggle_visibility, inputs=source_visible, outputs=[source_column, source_visible])
83
- toggle_chat.click(toggle_visibility, inputs=chat_visible, outputs=[chat_column, chat_visible])
84
- toggle_features.click(toggle_visibility, inputs=feature_visible, outputs=[feature_column, feature_visible])
85
 
86
  history = gr.State([])
87
  ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, chatbot])
 
33
  # 假資料模擬處理 RAG
34
  return f"已處理的文件: {', '.join(selected_paths)}"
35
 
36
+ def toggle_switch(state):
37
+ return gr.update(value=not state), not state
38
 
39
  with gr.Blocks() as demo:
40
  gr.Markdown("# AI Notes Assistant")
41
 
42
  with gr.Row():
43
+ source_toggle = gr.Checkbox(label="顯示來源選單", value=True)
44
+ chat_toggle = gr.Checkbox(label="顯示對話區域", value=True)
45
+ feature_toggle = gr.Checkbox(label="顯示功能卡片", value=True)
46
 
47
  with gr.Row():
48
  with gr.Column(visible=True) as source_column:
 
75
  with gr.Tab("其他功能"):
76
  gr.Markdown("此處可以添加更多功能卡片")
77
 
78
+ source_toggle.change(toggle_switch, inputs=source_toggle, outputs=[source_column, source_toggle])
79
+ chat_toggle.change(toggle_switch, inputs=chat_toggle, outputs=[chat_column, chat_toggle])
80
+ feature_toggle.change(toggle_switch, inputs=feature_toggle, outputs=[feature_column, feature_toggle])
 
 
 
 
81
 
82
  history = gr.State([])
83
  ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, chatbot])