Update app.py
Browse files
app.py
CHANGED
@@ -59,46 +59,41 @@ with gr.Blocks() as demo:
|
|
59 |
chat_toggle = gr.Checkbox(label="顯示對話區域", value=True)
|
60 |
feature_toggle = gr.Checkbox(label="顯示功能卡片", value=True)
|
61 |
|
62 |
-
with gr.Row():
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
file_list = gr.State([])
|
67 |
-
|
68 |
upload_file = gr.File(label="從電腦添加文件", file_types=[".txt", ".pdf", ".docx"])
|
69 |
add_file_button = gr.Button("添加到來源列表")
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
gr.
|
97 |
-
|
98 |
-
|
99 |
-
summary = gr.Textbox(label="摘要", interactive=False)
|
100 |
-
with gr.Tab("其他功能"):
|
101 |
-
gr.Markdown("此處可以添加更多功能卡片")
|
102 |
|
103 |
source_toggle.change(toggle_visibility, inputs=source_toggle, outputs=source_column)
|
104 |
chat_toggle.change(toggle_visibility, inputs=chat_toggle, outputs=chat_column)
|
@@ -108,4 +103,4 @@ with gr.Blocks() as demo:
|
|
108 |
ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, chatbot])
|
109 |
summary_button.click(mock_summary, inputs=[], outputs=[summary])
|
110 |
|
111 |
-
demo.launch()
|
|
|
59 |
chat_toggle = gr.Checkbox(label="顯示對話區域", value=True)
|
60 |
feature_toggle = gr.Checkbox(label="顯示功能卡片", value=True)
|
61 |
|
62 |
+
with gr.Row(visible=True) as source_column:
|
63 |
+
with gr.Tab("檔案來源"):
|
64 |
+
file_list = gr.State([])
|
65 |
+
with gr.Row():
|
|
|
|
|
66 |
upload_file = gr.File(label="從電腦添加文件", file_types=[".txt", ".pdf", ".docx"])
|
67 |
add_file_button = gr.Button("添加到來源列表")
|
68 |
+
file_display = gr.CheckboxGroup(label="已上傳的文件", interactive=True)
|
69 |
+
add_file_button.click(add_to_file_list, inputs=[upload_file, file_list], outputs=[file_display, upload_file])
|
70 |
+
rag_button = gr.Button("處理選擇的文件")
|
71 |
+
rag_result = gr.Textbox(label="處理結果", interactive=False)
|
72 |
+
rag_button.click(process_selected_files, inputs=[file_display, file_list], outputs=[rag_result])
|
73 |
+
|
74 |
+
with gr.Tab("YouTube來源"):
|
75 |
+
gr.Markdown("### YouTube 播放清單")
|
76 |
+
youtube_data = get_youtube_playlist()
|
77 |
+
youtube_choices = format_youtube_choices(youtube_data)
|
78 |
+
youtube_videos = gr.CheckboxGroup(choices=youtube_choices, label="可選擇的影片", interactive=True)
|
79 |
+
process_videos_button = gr.Button("處理選擇的影片")
|
80 |
+
video_result = gr.Textbox(label="影片處理結果", interactive=False)
|
81 |
+
process_videos_button.click(process_selected_videos, inputs=[youtube_videos], outputs=[video_result])
|
82 |
+
|
83 |
+
|
84 |
+
with gr.Row(visible=True) as chat_column:
|
85 |
+
gr.Markdown("### 對話區域")
|
86 |
+
chatbot = gr.Chatbot(label="聊天記錄", type="messages")
|
87 |
+
question = gr.Textbox(label="輸入問題,例如:文件的核心觀點是什麼?")
|
88 |
+
ask_button = gr.Button("提問")
|
89 |
+
|
90 |
+
with gr.Row(visible=True) as feature_column:
|
91 |
+
gr.Markdown("### 功能卡片")
|
92 |
+
with gr.Tab("摘要生成"):
|
93 |
+
summary_button = gr.Button("生成摘要")
|
94 |
+
summary = gr.Textbox(label="摘要", interactive=False)
|
95 |
+
with gr.Tab("其他功能"):
|
96 |
+
gr.Markdown("此處可以添加更多功能卡片")
|
|
|
|
|
|
|
97 |
|
98 |
source_toggle.change(toggle_visibility, inputs=source_toggle, outputs=source_column)
|
99 |
chat_toggle.change(toggle_visibility, inputs=chat_toggle, outputs=chat_column)
|
|
|
103 |
ask_button.click(mock_question_answer, inputs=[question, history], outputs=[chatbot, chatbot])
|
104 |
summary_button.click(mock_summary, inputs=[], outputs=[summary])
|
105 |
|
106 |
+
demo.launch()
|