layout
Browse files
app.py
CHANGED
@@ -68,44 +68,43 @@ with gr.Blocks() as demo:
|
|
68 |
chat_toggle = gr.Checkbox(label="顯示對話區域", value=True)
|
69 |
feature_toggle = gr.Checkbox(label="顯示功能卡片", value=True)
|
70 |
|
71 |
-
with gr.
|
72 |
-
gr.
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
with gr.Tab("YouTube 連結"):
|
82 |
-
youtube_link = gr.Textbox(label="輸入 YouTube 連結")
|
83 |
-
add_youtube_button = gr.Button("添加到來源列表")
|
84 |
-
add_youtube_button.click(add_youtube_to_list, inputs=[youtube_link, file_list], outputs=[file_list, youtube_link])
|
85 |
-
|
86 |
-
file_display = gr.CheckboxGroup(label="已上傳的文件", interactive=True)
|
87 |
-
|
88 |
-
process_files_button = gr.Button("處理檔案")
|
89 |
-
rag_result = gr.Textbox(label="處理結果", interactive=False)
|
90 |
-
|
91 |
-
process_files_button.click(process_all_files, inputs=[file_list], outputs=[rag_result])
|
92 |
-
file_list.change(lambda x: gr.update(choices = [os.path.basename(path) if os.path.basename(path) else path for path in x]), inputs=file_list, outputs=file_display)
|
93 |
-
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
source_toggle.change(toggle_visibility, inputs=source_toggle, outputs=source_column)
|
111 |
chat_toggle.change(toggle_visibility, inputs=chat_toggle, outputs=chat_column)
|
|
|
68 |
chat_toggle = gr.Checkbox(label="顯示對話區域", value=True)
|
69 |
feature_toggle = gr.Checkbox(label="顯示功能卡片", value=True)
|
70 |
|
71 |
+
with gr.Row():
|
72 |
+
with gr.Column(visible=True) as source_column:
|
73 |
+
gr.Markdown("### 來源選單")
|
74 |
+
|
75 |
+
file_list = gr.State([])
|
76 |
+
|
77 |
+
with gr.Tab("上傳檔案"):
|
78 |
+
upload_file = gr.File(label="從電腦添加文件", file_types=[".txt", ".pdf", ".docx"])
|
79 |
+
add_file_button = gr.Button("添加到來源列表")
|
80 |
+
add_file_button.click(add_to_file_list, inputs=[upload_file, file_list], outputs=[file_list, upload_file])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
with gr.Tab("YouTube 連結"):
|
83 |
+
youtube_link = gr.Textbox(label="輸入 YouTube 連結")
|
84 |
+
add_youtube_button = gr.Button("添加到來源列表")
|
85 |
+
add_youtube_button.click(add_youtube_to_list, inputs=[youtube_link, file_list], outputs=[file_list, youtube_link])
|
86 |
+
|
87 |
+
file_display = gr.CheckboxGroup(label="已上傳的文件", interactive=True)
|
88 |
+
|
89 |
+
process_files_button = gr.Button("處理檔案")
|
90 |
+
rag_result = gr.Textbox(label="處理結果", interactive=False)
|
91 |
+
|
92 |
+
process_files_button.click(process_all_files, inputs=[file_list], outputs=[rag_result])
|
93 |
+
file_list.change(lambda x: gr.update(choices = [os.path.basename(path) if os.path.basename(path) else path for path in x]), inputs=file_list, outputs=file_display)
|
94 |
+
|
95 |
+
with gr.Column(visible=True) as chat_column:
|
96 |
+
gr.Markdown("### 對話區域")
|
97 |
+
chatbot = gr.Chatbot(label="聊天記錄", type="messages")
|
98 |
+
question = gr.Textbox(label="輸入問題,例如:文件的核心觀點是什麼?")
|
99 |
+
ask_button = gr.Button("提問")
|
100 |
+
|
101 |
+
with gr.Column(visible=True) as feature_column:
|
102 |
+
gr.Markdown("### 功能卡片")
|
103 |
+
with gr.Tab("摘要生成"):
|
104 |
+
summary_button = gr.Button("生成摘要")
|
105 |
+
summary = gr.Textbox(label="摘要", interactive=False)
|
106 |
+
with gr.Tab("其他功能"):
|
107 |
+
gr.Markdown("此處可以添加更多功能卡片")
|
108 |
|
109 |
source_toggle.change(toggle_visibility, inputs=source_toggle, outputs=source_column)
|
110 |
chat_toggle.change(toggle_visibility, inputs=chat_toggle, outputs=chat_column)
|