When I tried to import create_stuff_documents_chain, I’m getting the error ModuleNotFoundError: No module named ‘langchain.chains’. Please help me to resolve. I’m using the latest version of langchain
(Version: 1.0.3)
Note: I have included below libs in requirements file
langchain
python-dotenv
langchain-openai
langchain-core
langchain-community
bs4
faiss-cpu
from langchain.chains.combine_documents import create_stuff_documents_chain
ModuleNotFoundError Traceback (most recent call last)
Cell In[11], line 1
----> 1 from langchain.chains.combine_documents import create_stuff_documents_chain
ModuleNotFoundError: No module named ‘langchain.chains’
1 Like
In LangChain 1.0, the langchain.chains module has been moved to the langchain-classic package.
To fix your error:
-
Install langchain-classic:
pip install langchain-classic
-
Update your import:
from langchain_classic.chains.combine_documents import create_stuff_documents_chain
Note: LangChain 1.0 recommends using create_agent instead of legacy chains for new projects. Legacy chains are maintained in langchain-classic for backward compatibility.
Check the RAG guide for current beste practices
3 Likes
For LangChain.js
In version 1.0, the langchain.chains module is moved to langchain/classic.
To fix it:
- Install the package:
npm i @langchain/classic
- Import:
import { createStuffDocumentsChain } from "@langchain/classic/chains/combine_documents";