Skip to content

Commit

Permalink
fix file load issue
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishesh committed Jun 14, 2024
1 parent bce4c4e commit e10a718
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ ollama pull nomic-embed-text
ollama pull mistral
ollama list
```
# Poetry

* Poetry
```shell
brew install poetry
```
Expand Down
17 changes: 9 additions & 8 deletions aichatbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e10a718

Please sign in to comment.