From e10a7183d9b82aa9be4ee5ed8a89b6564129ee53 Mon Sep 17 00:00:00 2001 From: Abhishesh Sharma Date: Fri, 14 Jun 2024 14:23:02 +0800 Subject: [PATCH] fix file load issue --- README.md | 3 ++- aichatbot/__main__.py | 17 +++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bd3a4f4..5836837 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,8 @@ ollama pull nomic-embed-text ollama pull mistral ollama list ``` -# Poetry + +* Poetry ```shell brew install poetry ``` diff --git a/aichatbot/__main__.py b/aichatbot/__main__.py index c01467a..4e9f00b 100644 --- a/aichatbot/__main__.py +++ b/aichatbot/__main__.py @@ -9,15 +9,16 @@ from langchain_core.runnables import RunnablePassthrough from langchain.retrievers.multi_query import MultiQueryRetriever + # Define the local path for the PDF file -with pkg_resources.path("aichatbot.resources", "bitcoin.pdf") as pdf_path: - local_path = str(pdf_path) - try: - loader = UnstructuredPDFLoader(file_path=local_path) - data = loader.load() - except Exception as e: - print("could not load file") - exit(1) +pdf_path = pkg_resources.files("aichatbot.resources").joinpath("bitcoin.pdf") +local_path = str(pdf_path) +try: + loader = UnstructuredPDFLoader(file_path=local_path) + data = loader.load() +except Exception as e: + print("could not load file") + exit(1) # Split and chunk the loaded data text_splitter = RecursiveCharacterTextSplitter(chunk_size=7500, chunk_overlap=100)