Update app.py
Browse files
app.py
CHANGED
@@ -74,15 +74,15 @@ NOTE : DESCRIBE/SUMMARY should always return the overall summary of the document
|
|
74 |
|
75 |
self.prompt = PromptTemplate(template=self.template, input_variables=["context", "question"])
|
76 |
|
77 |
-
def load_and_process_pdf(self, pdf_path):
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
|
87 |
def setup_conversation_chain(self):
|
88 |
self.qa_chain = ConversationalRetrievalChain.from_llm(
|
|
|
74 |
|
75 |
self.prompt = PromptTemplate(template=self.template, input_variables=["context", "question"])
|
76 |
|
77 |
+
def load_and_process_pdf(self, pdf_path):
|
78 |
+
try:
|
79 |
+
loader = PyPDFLoader(pdf_path)
|
80 |
+
documents = loader.load()
|
81 |
+
texts = self.text_splitter.split_documents(documents)
|
82 |
+
self.db = FAISS.from_documents(texts, self.embeddings)
|
83 |
+
self.setup_conversation_chain()
|
84 |
+
except Exception as e:
|
85 |
+
return f"An error occurred while processing the PDF: {e}"
|
86 |
|
87 |
def setup_conversation_chain(self):
|
88 |
self.qa_chain = ConversationalRetrievalChain.from_llm(
|