LLama3Rag / src /interface.py
hanzla's picture
new code
ae4a10a
raw
history blame
1.4 kB
import gradio as gr
def create_demo():
def on_upload(file, slider):
# Disable the slider when a file is uploaded
return gr.update(disabled=True), "PDF uploaded!"
with gr.Blocks(title="RAG Chatbot Q&A", theme="Soft") as demo:
with gr.Column():
with gr.Row():
chat_history = gr.Chatbot(value=[], elem_id='chatbot', height=680)
show_img = gr.Image(label='Overview', height=680)
with gr.Row():
with gr.Column(): # Adjust scale as needed
slider1 = gr.Slider(minimum=256, maximum=1024, value=256, label="Chunk Size")
with gr.Row():
with gr.Column(scale=0.60):
text_input = gr.Textbox(show_label=False, placeholder="Type here to ask your PDF", container=False)
with gr.Column(scale=0.20):
submit_button = gr.Button('Send')
with gr.Column(scale=0.20):
uploaded_pdf = gr.UploadButton("πŸ“ Upload PDF", file_types=[".pdf"])
# Linking the upload button to the slider update
uploaded_pdf.change(on_upload, inputs=[uploaded_pdf], outputs=[slider1])
return demo, chat_history, show_img, text_input, submit_button, uploaded_pdf, slider1
if __name__ == '__main__':
demo, chatbot, show_img, text_input, submit_button, uploaded_pdf, slider1 = create_demo()
demo.launch()