feat(oss): make spaCy an optional dependency
Move spacy from core dependencies to optional [nlp] extra. The system gracefully degrades without spaCy: - Lemmatization falls back to raw text - Entity extraction returns empty (no entity boost) - BM25 keyword search still works on raw text - Semantic search and additive scoring unaffected Install with NLP support: pip install mem0ai[nlp] Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
70c62ea54f
commit
9c9b3d54e2
@@ -90,6 +90,13 @@ Install the sdk via pip:
|
||||
pip install mem0ai
|
||||
```
|
||||
|
||||
For enhanced hybrid search with BM25 keyword matching and entity extraction, install with NLP support:
|
||||
|
||||
```bash
|
||||
pip install mem0ai[nlp]
|
||||
python -m spacy download en_core_web_sm
|
||||
```
|
||||
|
||||
Install sdk via npm:
|
||||
```bash
|
||||
npm install mem0ai
|
||||
|
||||
@@ -19,8 +19,13 @@ _lock = threading.Lock()
|
||||
|
||||
|
||||
def _ensure_model_available():
|
||||
"""Download en_core_web_sm if not already installed. Does not load the model."""
|
||||
import spacy
|
||||
"""Download en_core_web_sm if spaCy is installed but model is missing."""
|
||||
try:
|
||||
import spacy
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"spaCy is not installed. Install it with: pip install mem0ai[nlp]"
|
||||
)
|
||||
|
||||
if not spacy.util.is_package("en_core_web_sm"):
|
||||
logger.info("Downloading spaCy model en_core_web_sm...")
|
||||
|
||||
+3
-1
@@ -21,10 +21,12 @@ dependencies = [
|
||||
"pytz>=2024.1",
|
||||
"sqlalchemy>=2.0.31",
|
||||
"protobuf>=5.29.0,<6.0.0",
|
||||
"spacy>=3.7.0",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
nlp = [
|
||||
"spacy>=3.7.0",
|
||||
]
|
||||
graph = [
|
||||
"langchain-neo4j>=0.4.0",
|
||||
"langchain-aws>=0.2.23",
|
||||
|
||||
Reference in New Issue
Block a user