Spaces:
Runtime error
Runtime error
new code
Browse files- src/interface.py +12 -9
src/interface.py
CHANGED
|
@@ -1,8 +1,10 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
def create_demo():
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
with gr.Blocks(title="RAG Chatbot Q&A", theme="Soft") as demo:
|
| 8 |
with gr.Column():
|
|
@@ -12,21 +14,22 @@ def create_demo():
|
|
| 12 |
|
| 13 |
with gr.Row():
|
| 14 |
with gr.Column(): # Adjust scale as needed
|
| 15 |
-
slider1 = gr.Slider(minimum=256, maximum=1024, value=256, label="Chunk Size"
|
|
|
|
| 16 |
with gr.Row():
|
| 17 |
with gr.Column(scale=0.60):
|
| 18 |
-
text_input = gr.Textbox(
|
| 19 |
-
show_label=False,
|
| 20 |
-
placeholder="Type here to ask your PDF",
|
| 21 |
-
container=False)
|
| 22 |
with gr.Column(scale=0.20):
|
| 23 |
submit_button = gr.Button('Send')
|
| 24 |
with gr.Column(scale=0.20):
|
| 25 |
-
uploaded_pdf = gr.UploadButton("📁 Upload PDF", file_types=[".pdf"]
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
return demo, chat_history, show_img, text_input, submit_button, uploaded_pdf, slider1
|
| 28 |
|
|
|
|
| 29 |
if __name__ == '__main__':
|
| 30 |
demo, chatbot, show_img, text_input, submit_button, uploaded_pdf, slider1 = create_demo()
|
| 31 |
-
demo.queue()
|
| 32 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
|
| 4 |
def create_demo():
|
| 5 |
+
def on_upload(file, slider):
|
| 6 |
+
# Disable the slider when a file is uploaded
|
| 7 |
+
return gr.update(disabled=True), "PDF uploaded!"
|
| 8 |
|
| 9 |
with gr.Blocks(title="RAG Chatbot Q&A", theme="Soft") as demo:
|
| 10 |
with gr.Column():
|
|
|
|
| 14 |
|
| 15 |
with gr.Row():
|
| 16 |
with gr.Column(): # Adjust scale as needed
|
| 17 |
+
slider1 = gr.Slider(minimum=256, maximum=1024, value=256, label="Chunk Size")
|
| 18 |
+
|
| 19 |
with gr.Row():
|
| 20 |
with gr.Column(scale=0.60):
|
| 21 |
+
text_input = gr.Textbox(show_label=False, placeholder="Type here to ask your PDF", container=False)
|
|
|
|
|
|
|
|
|
|
| 22 |
with gr.Column(scale=0.20):
|
| 23 |
submit_button = gr.Button('Send')
|
| 24 |
with gr.Column(scale=0.20):
|
| 25 |
+
uploaded_pdf = gr.UploadButton("📁 Upload PDF", file_types=[".pdf"])
|
| 26 |
+
|
| 27 |
+
# Linking the upload button to the slider update
|
| 28 |
+
uploaded_pdf.change(on_upload, inputs=[uploaded_pdf], outputs=[slider1])
|
| 29 |
|
| 30 |
return demo, chat_history, show_img, text_input, submit_button, uploaded_pdf, slider1
|
| 31 |
|
| 32 |
+
|
| 33 |
if __name__ == '__main__':
|
| 34 |
demo, chatbot, show_img, text_input, submit_button, uploaded_pdf, slider1 = create_demo()
|
|
|
|
| 35 |
demo.launch()
|