Ignore non-string personal doc text (#1832)

This commit is contained in:
red person
2026-06-29 11:24:29 -07:00
committed by GitHub
parent 387f95187e
commit bbbe145247
2 changed files with 19 additions and 2 deletions
+4 -1
View File
@@ -68,6 +68,8 @@ def read_text_file(path: str) -> str:
def split_chunks(text: str, size: int = config.CHUNK_SIZE, overlap: int = config.CHUNK_OVERLAP) -> List[str]:
"""Split text into overlapping chunks."""
if not isinstance(text, str):
return []
text = text.strip()
if not text:
return []
@@ -87,7 +89,8 @@ def split_chunks(text: str, size: int = config.CHUNK_SIZE, overlap: int = config
def tokenize(s: str) -> Set[str]:
"""Tokenize string into words, excluding stop words."""
tokens = re.findall(r"[A-Za-z0-9_\-]+", (s or "").lower())
text = s if isinstance(s, str) else ""
tokens = re.findall(r"[A-Za-z0-9_\-]+", text.lower())
return set(t for t in tokens if t not in config.STOP_WORDS and len(t) > 1)
def load_personal_index(