Spaces:
Runtime error
Runtime error
new code
Browse files- src/app.py +2 -2
- src/interface.py +14 -14
src/app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
from interface import create_demo
|
2 |
from pdfchatbot import PDFChatBot
|
3 |
|
4 |
-
demo, chat_history, show_img, txt, submit_button, uploaded_pdf,
|
5 |
|
6 |
pdf_chatbot = PDFChatBot()
|
7 |
with demo:
|
8 |
-
uploaded_pdf.upload(pdf_chatbot.render_file, inputs=[uploaded_pdf,
|
9 |
|
10 |
submit_button.click(pdf_chatbot.add_text, inputs=[chat_history, txt], outputs=[chat_history], queue=False).\
|
11 |
success(pdf_chatbot.generate_response, inputs=[chat_history, txt, uploaded_pdf], outputs=[chat_history,txt]).\
|
|
|
1 |
from interface import create_demo
|
2 |
from pdfchatbot import PDFChatBot
|
3 |
|
4 |
+
demo, chat_history, show_img, txt, submit_button, uploaded_pdf, slider_chunk_size = create_demo()
|
5 |
|
6 |
pdf_chatbot = PDFChatBot()
|
7 |
with demo:
|
8 |
+
uploaded_pdf.upload(pdf_chatbot.render_file, inputs=[uploaded_pdf,slider_chunk_size], outputs=[show_img])
|
9 |
|
10 |
submit_button.click(pdf_chatbot.add_text, inputs=[chat_history, txt], outputs=[chat_history], queue=False).\
|
11 |
success(pdf_chatbot.generate_response, inputs=[chat_history, txt, uploaded_pdf], outputs=[chat_history,txt]).\
|
src/interface.py
CHANGED
@@ -2,24 +2,24 @@ import gradio as gr
|
|
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"
|
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.
|
21 |
-
with gr.
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
with gr.Row():
|
24 |
with gr.Column(scale=0.60):
|
25 |
text_input = gr.Textbox(
|
@@ -31,9 +31,9 @@ def create_demo():
|
|
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,
|
35 |
|
36 |
if __name__ == '__main__':
|
37 |
-
demo, chatbot, show_img, text_input, submit_button, uploaded_pdf,
|
38 |
demo.queue()
|
39 |
demo.launch()
|
|
|
2 |
|
3 |
# Gradio application setup
|
4 |
def create_demo():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
with gr.Blocks(title="RAG Chatbot Q&A", theme="Soft") as demo:
|
7 |
with gr.Column():
|
8 |
with gr.Row():
|
9 |
chat_history = gr.Chatbot(value=[], elem_id='chatbot', height=680)
|
10 |
show_img = gr.Image(label='Overview', height=680)
|
11 |
|
12 |
+
with gr.Column():
|
13 |
+
with gr.Row():
|
14 |
+
slider_chunk_size = gr.Slider(minimum=256, maximum=1024, value=256, label="Chunk Size", elem_id='slider1')
|
15 |
+
with gr.Row():
|
16 |
+
slider_overlap_percentage = gr.Slider(minimum=256, maximum=1024, value=256, label="Chunk Overlap Percentage", elem_id='slider2')
|
17 |
+
with gr.Column():
|
18 |
+
with gr.Row():
|
19 |
+
slider_temp = gr.Slider(minimum=256, maximum=1024, value=256, label="Model Temperature", elem_id='slider3')
|
20 |
+
with gr.Row():
|
21 |
+
slider_k = gr.Slider(minimum=256, maximum=1024, value=256, label="Max Chunks in Context", elem_id='slider2')
|
22 |
+
|
23 |
with gr.Row():
|
24 |
with gr.Column(scale=0.60):
|
25 |
text_input = gr.Textbox(
|
|
|
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, slider_chunk_size,slider_overlap_percentage,slider_temp,slider_k
|
35 |
|
36 |
if __name__ == '__main__':
|
37 |
+
demo, chatbot, show_img, text_input, submit_button, uploaded_pdf, slider_chunk_size,slider_overlap_percentage,slider_temp,slider_k = create_demo()
|
38 |
demo.queue()
|
39 |
demo.launch()
|