Spaces:
Running
Running
Commit
·
2c230be
1
Parent(s):
2b30343
adding online PDF loader
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
-
from langchain.document_loaders import PDFMinerLoader,CSVLoader ,UnstructuredWordDocumentLoader,TextLoader
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
from langchain.embeddings import SentenceTransformerEmbeddings
|
| 7 |
from langchain.vectorstores import FAISS
|
|
@@ -91,7 +91,7 @@ def process_word_document(document_file_name):
|
|
| 91 |
|
| 92 |
|
| 93 |
def process_pdf_document(document_file_name):
|
| 94 |
-
loader =
|
| 95 |
document = loader.load()[0]
|
| 96 |
return document
|
| 97 |
|
|
@@ -125,8 +125,8 @@ with gr.Blocks(css=css) as demo:
|
|
| 125 |
with gr.Box():
|
| 126 |
pdf_doc = gr.File(label="Upload File to start QA", file_types=FILE_EXT, type="file")
|
| 127 |
with gr.Row():
|
| 128 |
-
load_pdf = gr.Button("Load file to langchain")
|
| 129 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=True)
|
|
|
|
| 130 |
|
| 131 |
chatbot = gr.Chatbot()
|
| 132 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|
|
|
|
| 1 |
import os
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
from langchain.document_loaders import PDFMinerLoader,CSVLoader ,UnstructuredWordDocumentLoader,TextLoader,OnlinePDFLoader
|
| 5 |
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
| 6 |
from langchain.embeddings import SentenceTransformerEmbeddings
|
| 7 |
from langchain.vectorstores import FAISS
|
|
|
|
| 91 |
|
| 92 |
|
| 93 |
def process_pdf_document(document_file_name):
|
| 94 |
+
loader = OnlinePDFLoader(document_file_name)
|
| 95 |
document = loader.load()[0]
|
| 96 |
return document
|
| 97 |
|
|
|
|
| 125 |
with gr.Box():
|
| 126 |
pdf_doc = gr.File(label="Upload File to start QA", file_types=FILE_EXT, type="file")
|
| 127 |
with gr.Row():
|
|
|
|
| 128 |
langchain_status = gr.Textbox(label="Status", placeholder="", interactive=True)
|
| 129 |
+
load_pdf = gr.Button("Upload file and generate Embeddings",).style(full_width=False)
|
| 130 |
|
| 131 |
chatbot = gr.Chatbot()
|
| 132 |
question = gr.Textbox(label="Question", placeholder="Type your question and hit Enter")
|