|
10 | 10 | from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor, as_completed |
11 | 11 | from langchain_community.docstore.document import Document |
12 | 12 | from langchain_text_splitters.character import RecursiveCharacterTextSplitter |
13 | | -from langchain_text_splitters.base import TextSplitter # ← added |
14 | | -# ─ monkey-patch block starts |
15 | | -_old_merge = TextSplitter._merge_splits |
16 | | -def _debug_merge(self, splits, separator): |
17 | | - print(">>> _length_function TYPE *inside* _merge_splits:", type(self._length_function)) |
18 | | - return _old_merge(self, splits, separator) |
19 | | -TextSplitter._merge_splits = _debug_merge |
20 | | -# ─ monkey-patch block ends |
| 13 | +from langchain_text_splitters.base import TextSplitter |
| 14 | +# # ─ monkey-patch block starts |
| 15 | +# _old_merge = TextSplitter._merge_splits |
| 16 | +# def _debug_merge(self, splits, separator): |
| 17 | + # print(">>> _length_function TYPE *inside* _merge_splits:", type(self._length_function)) |
| 18 | + # return _old_merge(self, splits, separator) |
| 19 | +# TextSplitter._merge_splits = _debug_merge |
| 20 | +# # ─ monkey-patch block ends |
21 | 21 | from langchain_community.document_loaders import ( |
22 | 22 | PyMuPDFLoader, |
23 | 23 | Docx2txtLoader, |
@@ -223,8 +223,9 @@ def split_documents(documents=None, text_documents_pdf=None): |
223 | 223 | keep_separator = False, |
224 | 224 | ) |
225 | 225 |
|
226 | | - print("TYPE OF _length_function:", type(text_splitter._length_function)) |
227 | | - import time; time.sleep(20) |
| 226 | + # DEBUG WITH MONKEY PATCCH |
| 227 | + # print("TYPE OF _length_function:", type(text_splitter._length_function)) |
| 228 | + # import time; time.sleep(20) |
228 | 229 | """ |
229 | 230 | Run the script once; if it prints <class 'function'>, the attribute is still correct at creation time and gets corrupted |
230 | 231 | later, so you’ll know to trace subsequent mutations. If it already shows <class 'list'> (or anything other than function), |
|
0 commit comments