Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
)
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|