Update app.py
Browse files
app.py
CHANGED
@@ -64,14 +64,15 @@ def index_pdf(pdf):
|
|
64 |
|
65 |
return "PDF indexed successfully!"
|
66 |
|
67 |
-
def load_sample_pdf(
|
68 |
global vector_store
|
|
|
69 |
|
70 |
# Load the PDFs
|
71 |
-
|
72 |
-
|
73 |
-
for loader in loaders:
|
74 |
documents.extend(loader.load())
|
|
|
75 |
|
76 |
# Split the documents into chunks
|
77 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1024, chunk_overlap=64)
|
@@ -144,7 +145,7 @@ with gr.Blocks(theme="Nymbo/Alyx_Theme") as demo:
|
|
144 |
sample_description = gr.Markdown("This sample PDF is a seminal paper in the field of machine learning, titled 'Attention Is All You Need' at https://arxiv.org/abs/1706.03762. It introduces the Transformer model, which has become foundational in natural language processing.")
|
145 |
index_output = gr.Textbox(label="Indexing Status")
|
146 |
# index_button.click(index_pdf, inputs=pdf_input, outputs=index_output)
|
147 |
-
load_sample.click(load_sample_pdf, inputs=
|
148 |
|
149 |
with gr.Tab("Chatbot"):
|
150 |
gr.ChatInterface(
|
|
|
64 |
|
65 |
return "PDF indexed successfully!"
|
66 |
|
67 |
+
def load_sample_pdf():
|
68 |
global vector_store
|
69 |
+
documents = []
|
70 |
|
71 |
# Load the PDFs
|
72 |
+
for file in sample_filenames:
|
73 |
+
loader = PyPDFLoader(file)
|
|
|
74 |
documents.extend(loader.load())
|
75 |
+
print(f"{file} is processed!")
|
76 |
|
77 |
# Split the documents into chunks
|
78 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=1024, chunk_overlap=64)
|
|
|
145 |
sample_description = gr.Markdown("This sample PDF is a seminal paper in the field of machine learning, titled 'Attention Is All You Need' at https://arxiv.org/abs/1706.03762. It introduces the Transformer model, which has become foundational in natural language processing.")
|
146 |
index_output = gr.Textbox(label="Indexing Status")
|
147 |
# index_button.click(index_pdf, inputs=pdf_input, outputs=index_output)
|
148 |
+
load_sample.click(load_sample_pdf, inputs=None, outputs=index_output)
|
149 |
|
150 |
with gr.Tab("Chatbot"):
|
151 |
gr.ChatInterface(
|