wu981526092 Claude commited on
Commit
0b205c4
·
1 Parent(s): 87ee823

Fix: Add langchain-text-splitters dependency for LangChain 0.3+ compatibility

Browse files

In LangChain 0.3+, the text_splitter module was moved to a separate package
langchain-text-splitters. This fixes the "No module named 'langchain.text_splitter'"
error when deploying to Hugging Face Spaces.

Changes:
- Added langchain-text-splitters>=0.3.0 to pyproject.toml dependencies
- Updated import in text_chunking_strategies.py to use langchain_text_splitters
- Explicitly install langchain-text-splitters in Dockerfile

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Dockerfile CHANGED
@@ -34,11 +34,12 @@ WORKDIR /app
34
  COPY --chown=user pyproject.toml ./
35
 
36
  # Install dependencies directly with pip (more reliable than uv)
37
- # Force fresh install with langchain packages (2025-10-15)
38
  RUN pip install --user --upgrade pip && \
39
  pip install --user --timeout=600 --retries=3 --no-cache-dir \
40
  "langchain>=0.3.0" \
41
- "langchain-community>=0.3.0" && \
 
42
  pip install --user --timeout=600 --retries=3 --no-cache-dir -e .
43
 
44
  # Copy application code with proper ownership
 
34
  COPY --chown=user pyproject.toml ./
35
 
36
  # Install dependencies directly with pip (more reliable than uv)
37
+ # Force fresh install with langchain packages (2025-10-23)
38
  RUN pip install --user --upgrade pip && \
39
  pip install --user --timeout=600 --retries=3 --no-cache-dir \
40
  "langchain>=0.3.0" \
41
+ "langchain-community>=0.3.0" \
42
+ "langchain-text-splitters>=0.3.0" && \
43
  pip install --user --timeout=600 --retries=3 --no-cache-dir -e .
44
 
45
  # Copy application code with proper ownership
agentgraph/input/text_processing/text_chunking_strategies.py CHANGED
@@ -12,7 +12,7 @@ from dataclasses import dataclass
12
  from datetime import datetime
13
  from typing import Dict, Any, List, Tuple, Optional
14
 
15
- from langchain.text_splitter import RecursiveCharacterTextSplitter
16
  from langchain_community.document_loaders import JSONLoader
17
 
18
  # Import agent-aware components
 
12
  from datetime import datetime
13
  from typing import Dict, Any, List, Tuple, Optional
14
 
15
+ from langchain_text_splitters import RecursiveCharacterTextSplitter
16
  from langchain_community.document_loaders import JSONLoader
17
 
18
  # Import agent-aware components
pyproject.toml CHANGED
@@ -45,6 +45,7 @@ dependencies = [
45
  "langsmith>=0.3.38", # ✅ 核心 (12+ 使用)
46
  "langchain>=0.3.0", # ✅ 核心 (text splitting)
47
  "langchain-community>=0.3.0", # ✅ 核心 (document loaders)
 
48
  "crewai>=0.108.0", # ✅ 功能性 (2+ 使用)
49
  "crewai-tools>=0.38.1", # ✅ 功能性
50
  "langgraph>=0.5.3", # ✅ 功能性
 
45
  "langsmith>=0.3.38", # ✅ 核心 (12+ 使用)
46
  "langchain>=0.3.0", # ✅ 核心 (text splitting)
47
  "langchain-community>=0.3.0", # ✅ 核心 (document loaders)
48
+ "langchain-text-splitters>=0.3.0", # ✅ 核心 (text splitting - required for langchain 0.3+)
49
  "crewai>=0.108.0", # ✅ 功能性 (2+ 使用)
50
  "crewai-tools>=0.38.1", # ✅ 功能性
51
  "langgraph>=0.5.3", # ✅ 功能性