new code
Browse files- src/interface.py +12 -4
src/interface.py
CHANGED
@@ -2,16 +2,24 @@ import gradio as gr
|
|
2 |
|
3 |
# Gradio application setup
|
4 |
def create_demo():
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
with gr.Column():
|
7 |
with gr.Row():
|
8 |
chat_history = gr.Chatbot(value=[], elem_id='chatbot', height=680)
|
9 |
show_img = gr.Image(label='Overview', height=680)
|
10 |
|
11 |
with gr.Row():
|
12 |
-
# Add sliders here
|
13 |
with gr.Column(): # Adjust scale as needed
|
14 |
-
slider1 = gr.Slider(minimum=256, maximum=1024, value=256, label="Chunk Size")
|
15 |
with gr.Row():
|
16 |
with gr.Column(scale=0.60):
|
17 |
text_input = gr.Textbox(
|
@@ -21,7 +29,7 @@ def create_demo():
|
|
21 |
with gr.Column(scale=0.20):
|
22 |
submit_button = gr.Button('Send')
|
23 |
with gr.Column(scale=0.20):
|
24 |
-
uploaded_pdf = gr.UploadButton("📁 Upload PDF", file_types=[".pdf"])
|
25 |
|
26 |
return demo, chat_history, show_img, text_input, submit_button, uploaded_pdf, slider1
|
27 |
|
|
|
2 |
|
3 |
# Gradio application setup
|
4 |
def create_demo():
|
5 |
+
# JavaScript to disable the slider after the upload button is pressed
|
6 |
+
javascript = """
|
7 |
+
document.querySelector('input[type=file]').addEventListener('change', function() {
|
8 |
+
if (this.files.length > 0) {
|
9 |
+
document.getElementById('slider1').setAttribute('disabled', true);
|
10 |
+
}
|
11 |
+
});
|
12 |
+
"""
|
13 |
+
|
14 |
+
with gr.Blocks(title="RAG Chatbot Q&A", theme="Soft", js=javascript) as demo:
|
15 |
with gr.Column():
|
16 |
with gr.Row():
|
17 |
chat_history = gr.Chatbot(value=[], elem_id='chatbot', height=680)
|
18 |
show_img = gr.Image(label='Overview', height=680)
|
19 |
|
20 |
with gr.Row():
|
|
|
21 |
with gr.Column(): # Adjust scale as needed
|
22 |
+
slider1 = gr.Slider(minimum=256, maximum=1024, value=256, label="Chunk Size", elem_id='slider1')
|
23 |
with gr.Row():
|
24 |
with gr.Column(scale=0.60):
|
25 |
text_input = gr.Textbox(
|
|
|
29 |
with gr.Column(scale=0.20):
|
30 |
submit_button = gr.Button('Send')
|
31 |
with gr.Column(scale=0.20):
|
32 |
+
uploaded_pdf = gr.UploadButton("📁 Upload PDF", file_types=[".pdf"], elem_id='upload_pdf')
|
33 |
|
34 |
return demo, chat_history, show_img, text_input, submit_button, uploaded_pdf, slider1
|
35 |
|