Update app.py
Browse files
app.py
CHANGED
@@ -23,20 +23,20 @@ with gr.Blocks() as demo:
|
|
23 |
gr.Markdown("# AI Notes Assistant")
|
24 |
|
25 |
with gr.Row():
|
26 |
-
with gr.Column():
|
27 |
gr.Markdown("### 來源選單")
|
28 |
sources = gr.CheckboxGroup(
|
29 |
choices=mock_sources(), label="選取所有來源", interactive=True
|
30 |
)
|
31 |
upload_file = gr.File(label="從電腦添加文件", file_types=[".txt", ".pdf", ".docx"])
|
32 |
|
33 |
-
with gr.Column():
|
34 |
gr.Markdown("### 對話區域")
|
35 |
chatbot = gr.Chatbot(label="聊天記錄")
|
36 |
question = gr.Textbox(label="輸入問題,例如:文件的核心觀點是什麼?")
|
37 |
ask_button = gr.Button("提問")
|
38 |
|
39 |
-
with gr.Column():
|
40 |
gr.Markdown("### 功能卡片")
|
41 |
with gr.Tab("摘要生成"):
|
42 |
summary_button = gr.Button("生成摘要")
|
@@ -44,7 +44,20 @@ with gr.Blocks() as demo:
|
|
44 |
with gr.Tab("其他功能"):
|
45 |
gr.Markdown("此處可以添加更多功能卡片")
|
46 |
|
|
|
|
|
|
|
|
|
|
|
47 |
history = gr.State([])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, chatbot])
|
49 |
summary_button.click(mock_summary, inputs=[], outputs=[summary])
|
50 |
|
|
|
23 |
gr.Markdown("# AI Notes Assistant")
|
24 |
|
25 |
with gr.Row():
|
26 |
+
with gr.Column() as source_column:
|
27 |
gr.Markdown("### 來源選單")
|
28 |
sources = gr.CheckboxGroup(
|
29 |
choices=mock_sources(), label="選取所有來源", interactive=True
|
30 |
)
|
31 |
upload_file = gr.File(label="從電腦添加文件", file_types=[".txt", ".pdf", ".docx"])
|
32 |
|
33 |
+
with gr.Column() as chat_column:
|
34 |
gr.Markdown("### 對話區域")
|
35 |
chatbot = gr.Chatbot(label="聊天記錄")
|
36 |
question = gr.Textbox(label="輸入問題,例如:文件的核心觀點是什麼?")
|
37 |
ask_button = gr.Button("提問")
|
38 |
|
39 |
+
with gr.Column() as feature_column:
|
40 |
gr.Markdown("### 功能卡片")
|
41 |
with gr.Tab("摘要生成"):
|
42 |
summary_button = gr.Button("生成摘要")
|
|
|
44 |
with gr.Tab("其他功能"):
|
45 |
gr.Markdown("此處可以添加更多功能卡片")
|
46 |
|
47 |
+
with gr.Row():
|
48 |
+
toggle_sources = gr.Button("顯示/隱藏 來源選單")
|
49 |
+
toggle_chat = gr.Button("顯示/隱藏 對話區域")
|
50 |
+
toggle_features = gr.Button("顯示/隱藏 功能卡片")
|
51 |
+
|
52 |
history = gr.State([])
|
53 |
+
|
54 |
+
def toggle_visibility(toggle_state, component):
|
55 |
+
return gr.update(visible=not toggle_state)
|
56 |
+
|
57 |
+
toggle_sources.click(toggle_visibility, inputs=[source_column.visible], outputs=[source_column])
|
58 |
+
toggle_chat.click(toggle_visibility, inputs=[chat_column.visible], outputs=[chat_column])
|
59 |
+
toggle_features.click(toggle_visibility, inputs=[feature_column.visible], outputs=[feature_column])
|
60 |
+
|
61 |
ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, chatbot])
|
62 |
summary_button.click(mock_summary, inputs=[], outputs=[summary])
|
63 |
|