-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwb.py
More file actions
25 lines (20 loc) · 757 Bytes
/
wb.py
File metadata and controls
25 lines (20 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pypdf
from langchain_community.document_loaders import PyPDFLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain.schema.document import Document
from langchain_community.embeddings import OllamaEmbeddings
def embed_func():
embedding = OllamaEmbeddings(model='llama3.1')
return embedding
def split_documents(documents: list[Document]):
text_splitter = RecursiveCharacterTextSplitter(
chunk_size=800,
chunk_overlap=80,
length_function=len,
is_separator_regex=False,
)
return text_splitter.split_documents(documents)
loader = PyPDFLoader('purchase.pdf')
purchase_page = loader.load()
loader_1 = PyPDFLoader('remdemption.pdf')
redemption_page = loader_1.load()