Manglik-R commited on
Commit
f8bb443
·
verified ·
1 Parent(s): d581fc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -25
app.py CHANGED
@@ -1,7 +1,5 @@
1
  import os
2
  import sys
3
- import gradio.inputs as gr_inputs
4
- import gradio.outputs as gr_outputs
5
  import gradio as gr
6
  from pinecone import Pinecone, ServerlessSpec
7
  from langchain_community.llms import Replicate
@@ -86,26 +84,18 @@ title_html = """
86
  <h1>Chat with PDF</h1>
87
  """
88
 
89
- iface = gr.Interface(
90
- fn=process_pdf,
91
- inputs=gr_inputs.File(label="Load a PDF", type="file", accept=".pdf"),
92
- outputs=gr_outputs.Textbox(label="Status", type="auto", default=""),
93
- title="PDF Chatbot Interface",
94
- description="Upload a PDF file to start interacting with the chatbot.",
95
- allow_flagging=False,
96
- css=css
97
- )
98
-
99
- # Add chat history and question input to the interface
100
- chatbot_interface = gr.Interface(
101
- fn=query,
102
- inputs=gr_inputs.Textbox(label="Question", placeholder="Type your question and hit Enter"),
103
- outputs=gr_outputs.Textbox(label="Chat History", type="auto", default=""),
104
- title=title_html,
105
- live=True,
106
- css=css
107
- )
108
-
109
- # Launch the combined interface
110
- iface.launch()
111
- chatbot_interface.launch()
 
1
  import os
2
  import sys
 
 
3
  import gradio as gr
4
  from pinecone import Pinecone, ServerlessSpec
5
  from langchain_community.llms import Replicate
 
84
  <h1>Chat with PDF</h1>
85
  """
86
 
87
+ with gr.Blocks(css=css) as demo:
88
+ with gr.Column(elem_id="col-container"):
89
+ gr.HTML(title)
90
+ with gr.Column():
91
+ pdf_doc = gr.File(label="Load a PDF", file_types=['.pdf'], type="file")
92
+ load_pdf = gr.Button("Load PDF")
93
+ langchain_status = gr.Textbox(label="Status", placeholder="", interactive=False)
94
+ chatbot = gr.Chatbot([], elem_id="chatbot").style(height=350)
95
+ question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter ")
96
+ submit_btn = gr.Button("Send message")
97
+ load_pdf.click(pdf_changes, inputs=[pdf_doc], outputs=[langchain_status], queue=False)
98
+ question.submit(query, [chatbot, question], [chatbot, question])
99
+ submit_btn.click(query, [chatbot, question], [chatbot, question])
100
+
101
+ demo.launch()