Skip to content

Commit 79b1661

Browse files
feat: add all_texts property to lazily cache document texts for retrieval
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <[email protected]>
1 parent 7b45948 commit 79b1661

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

wdoc/wdoc.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,18 @@ def output_handler(text: str) -> str:
19301930

19311931
return output
19321932

1933+
@property
1934+
def all_texts(self) -> List[str]:
1935+
"""
1936+
Lazily create and cache all_texts from loaded_embeddings.
1937+
This property is only computed when needed by specific retrievers (KNN, SVM).
1938+
"""
1939+
if not hasattr(self, '_all_texts'):
1940+
self._all_texts = [
1941+
v.page_content for k, v in self.loaded_embeddings.docstore._dict.items()
1942+
]
1943+
return self._all_texts
1944+
19331945
@staticmethod
19341946
@set_parse_doc_help_md_as_docstring
19351947
def parse_doc(

0 commit comments

Comments
 (0)