import gradio as gr # ... other imports # ... functions css = """ #col-container {max-width: 700px; margin-left: auto; margin-right: auto;} """ title = """

Chat with PDF

Upload a .PDF from your computer, click the "Load PDF to LangChain" button,
when everything is ready, you can start asking questions about the pdf ;)

Duplicate Space
""" with gr.Blocks(css=css) as demo: with gr.Column(elem_id="col-container"): gr.HTML(title) with gr.Column(): pdf_doc = gr.File(label="Load a pdf", file_types=['.pdf'], type="filepath") # Corrected `type` repo_id = gr.Dropdown(label="LLM", choices=["google/flan-ul2", "OpenAssistant/oasst-sft-1-pythia-12b", "bigscience/bloomz"], value="google/flan-ul2") with gr.Row(): langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False) load_pdf = gr.Button("Load pdf to langchain") chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350) question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ") submit_btn = gr.Button("Send message") # ... event handlers demo.launch()