From 901393a19aef820670758a0de302b00855b0e7da Mon Sep 17 00:00:00 2001 From: Netra Prasad Neupane <39429615+np-n@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:12:10 +0545 Subject: [PATCH 1/2] support modular langchain as well --- .../pipelines/components/retriever/base.py | 16 +++++++++++++--- setup.py | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/paddlex/inference/pipelines/components/retriever/base.py b/paddlex/inference/pipelines/components/retriever/base.py index a348836836..b4f067951e 100644 --- a/paddlex/inference/pipelines/components/retriever/base.py +++ b/paddlex/inference/pipelines/components/retriever/base.py @@ -21,13 +21,23 @@ from .....utils.deps import class_requires_deps, is_dep_available from .....utils.subclass_register import AutoRegisterABCMetaClass -if is_dep_available("langchain"): - from langchain.docstore.document import Document - from langchain.text_splitter import RecursiveCharacterTextSplitter + if is_dep_available("langchain-community"): from langchain_community import vectorstores from langchain_community.vectorstores import FAISS +# Document import capability +try: + from langchain_core.documents import Document +except ImportError: + from langchain.docstore.document import Document + +# Text splitter compatibility +try: + from langchain_text_splitters import RecursiveCharacterTextSplitter +except ImportError: + from langchain.text_splitter import RecursiveCharacterTextSplitter + @class_requires_deps("langchain", "langchain-community") class BaseRetriever(ABC, metaclass=AutoRegisterABCMetaClass): diff --git a/setup.py b/setup.py index b02f516f2a..c5018ace36 100644 --- a/setup.py +++ b/setup.py @@ -44,6 +44,7 @@ "langchain-community": ">= 0.2, < 1.0", "langchain-core": "", "langchain-openai": ">= 0.1, < 1.0", + "langchain_text_splitters": "", "lxml": "", "matplotlib": "", "modelscope": ">=1.28.0", From b39f4308ba781fed72a0cbcd214429a5d9dd528b Mon Sep 17 00:00:00 2001 From: Netra Prasad Neupane <39429615+np-n@users.noreply.github.com> Date: Wed, 25 Feb 2026 13:14:41 +0545 Subject: [PATCH 2/2] fix --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index c5018ace36..a3a43d9f88 100644 --- a/setup.py +++ b/setup.py @@ -40,10 +40,10 @@ "jieba": "", "Jinja2": "", "joblib": "", - "langchain": ">= 0.2, < 1.0", - "langchain-community": ">= 0.2, < 1.0", + "langchain": ">= 0.2", + "langchain-community": ">= 0.2", "langchain-core": "", - "langchain-openai": ">= 0.1, < 1.0", + "langchain-openai": ">= 0.1", "langchain_text_splitters": "", "lxml": "", "matplotlib": "",