Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(embeddings): import text splitters from concrete submodules, not package root (#4493)

LearningCircuit006e2116cf74
diff --git a/changelog.d/4490.bugfix.md b/changelog.d/4490.bugfix.md
new file mode 100644
index 0000000000..7f45eacd7d
--- /dev/null
+++ b/changelog.d/4490.bugfix.md
@@ -0,0 +1 @@
+Hardened app startup against unrelated broken packages in the user's site-packages: the text-splitter registry now imports the three splitters it uses directly from their `langchain_text_splitters` submodules instead of the package root, whose `__init__` eagerly imports every optional splitter backend (spacy, nltk, konlpy, ...). Previously, a globally installed spacy paired with an incompatible typer/click combination crashed `ldr-web` at startup with `TypeError: type 'Choice' is not subscriptable`.
diff --git a/src/local_deep_research/embeddings/splitters/text_splitter_registry.py b/src/local_deep_research/embeddings/splitters/text_splitter_registry.py
index b89dee0510..f92ad3efec 100644
--- a/src/local_deep_research/embeddings/splitters/text_splitter_registry.py
+++ b/src/local_deep_research/embeddings/splitters/text_splitter_registry.py
@@ -6,9 +6,14 @@ based on configuration, similar to how embeddings_config.py works for embeddings
"""
from typing import Optional, List, Any
-from langchain_text_splitters import (
- RecursiveCharacterTextSplitter,
- TokenTextSplitter,
+
+# Import from concrete submodules instead of the package root: the root
+# __init__ eagerly imports every splitter module (spacy, nltk, konlpy, ...),
+# so a broken optional package in the user's site-packages would crash app
+# startup via the scheduler import chain (see issue #4490).
+from langchain_text_splitters.base import TokenTextSplitter
+from langchain_text_splitters.character import RecursiveCharacterTextSplitter
+from langchain_text_splitters.sentence_transformers import (
SentenceTransformersTokenTextSplitter,
)
from langchain_core.embeddings import Embeddings