Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,6 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
def mock_question_answer(question, history):
|
4 |
# εθ³ζ樑ζ¬εη
|
@@ -18,12 +20,16 @@ def mock_summary():
|
|
18 |
|
19 |
def add_to_file_list(file, file_list):
|
20 |
if file:
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
25 |
# εθ³ζ樑ζ¬θη RAG
|
26 |
-
return f"ε·²θηηζδ»Ά: {', '.join(
|
27 |
|
28 |
def toggle_visibility(current_state):
|
29 |
return gr.update(visible=not current_state)
|
@@ -51,7 +57,7 @@ with gr.Blocks() as demo:
|
|
51 |
rag_button = gr.Button("θηιΈζηζδ»Ά")
|
52 |
rag_result = gr.Textbox(label="θηη΅ζ", interactive=False)
|
53 |
|
54 |
-
rag_button.click(process_selected_files, inputs=[file_display], outputs=[rag_result])
|
55 |
|
56 |
with gr.Column(visible=True) as chat_column:
|
57 |
gr.Markdown("### ε°θ©±εε")
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
+
import shutil
|
4 |
|
5 |
def mock_question_answer(question, history):
|
6 |
# εθ³ζ樑ζ¬εη
|
|
|
20 |
|
21 |
def add_to_file_list(file, file_list):
|
22 |
if file:
|
23 |
+
temp_path = f"/tmp/{file.name}"
|
24 |
+
shutil.copy(file.name, temp_path) # ε°ζδ»Άεε²ε° /tmp
|
25 |
+
file_list.append(temp_path)
|
26 |
+
display_list = [os.path.basename(path) for path in file_list]
|
27 |
+
return gr.update(choices=display_list), None # ζΈ
η©Ίζδ»ΆιΈζζ‘
|
28 |
+
|
29 |
+
def process_selected_files(selected_files, file_list):
|
30 |
+
selected_paths = [path for path in file_list if os.path.basename(path) in selected_files]
|
31 |
# εθ³ζ樑ζ¬θη RAG
|
32 |
+
return f"ε·²θηηζδ»Ά: {', '.join(selected_paths)}"
|
33 |
|
34 |
def toggle_visibility(current_state):
|
35 |
return gr.update(visible=not current_state)
|
|
|
57 |
rag_button = gr.Button("θηιΈζηζδ»Ά")
|
58 |
rag_result = gr.Textbox(label="θηη΅ζ", interactive=False)
|
59 |
|
60 |
+
rag_button.click(process_selected_files, inputs=[file_display, file_list], outputs=[rag_result])
|
61 |
|
62 |
with gr.Column(visible=True) as chat_column:
|
63 |
gr.Markdown("### ε°θ©±εε")
|