From 6dc9c8feaee1c4fbfeb4f3afbae8391d4164c698 Mon Sep 17 00:00:00 2001 From: Chester Curme Date: Wed, 25 Sep 2024 08:37:58 -0400 Subject: [PATCH] add deprecation warnings --- .../langchain/chains/combine_documents/map_reduce.py | 10 ++++++++++ .../langchain/chains/combine_documents/map_rerank.py | 10 ++++++++++ .../langchain/chains/combine_documents/reduce.py | 10 ++++++++++ .../langchain/chains/combine_documents/refine.py | 10 ++++++++++ 4 files changed, 40 insertions(+) diff --git a/libs/langchain/langchain/chains/combine_documents/map_reduce.py b/libs/langchain/langchain/chains/combine_documents/map_reduce.py index 7b4885cdea4fe..b72693f625a54 100644 --- a/libs/langchain/langchain/chains/combine_documents/map_reduce.py +++ b/libs/langchain/langchain/chains/combine_documents/map_reduce.py @@ -4,6 +4,7 @@ from typing import Any, Dict, List, Optional, Tuple, Type +from langchain_core._api import deprecated from langchain_core.callbacks import Callbacks from langchain_core.documents import Document from langchain_core.runnables.config import RunnableConfig @@ -15,6 +16,15 @@ from langchain.chains.llm import LLMChain +@deprecated( + since="0.3.1", + removal="1.0", + message=( + "This class is deprecated. Please see the migration guide here for " + "a recommended replacement: " + "https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain/" + ), +) class MapReduceDocumentsChain(BaseCombineDocumentsChain): """Combining documents by mapping a chain over them, then combining results. diff --git a/libs/langchain/langchain/chains/combine_documents/map_rerank.py b/libs/langchain/langchain/chains/combine_documents/map_rerank.py index 61e6e226ed65d..8ba353293ce37 100644 --- a/libs/langchain/langchain/chains/combine_documents/map_rerank.py +++ b/libs/langchain/langchain/chains/combine_documents/map_rerank.py @@ -4,6 +4,7 @@ from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union, cast +from langchain_core._api import deprecated from langchain_core.callbacks import Callbacks from langchain_core.documents import Document from langchain_core.runnables.config import RunnableConfig @@ -16,6 +17,15 @@ from langchain.output_parsers.regex import RegexParser +@deprecated( + since="0.3.1", + removal="1.0", + message=( + "This class is deprecated. Please see the migration guide here for " + "a recommended replacement: " + "https://python.langchain.com/docs/versions/migrating_chains/map_rerank_docs_chain/" # noqa: E501 + ), +) class MapRerankDocumentsChain(BaseCombineDocumentsChain): """Combining documents by mapping a chain over them, then reranking results. diff --git a/libs/langchain/langchain/chains/combine_documents/reduce.py b/libs/langchain/langchain/chains/combine_documents/reduce.py index 662be15e38b55..8acc3f88b5417 100644 --- a/libs/langchain/langchain/chains/combine_documents/reduce.py +++ b/libs/langchain/langchain/chains/combine_documents/reduce.py @@ -4,6 +4,7 @@ from typing import Any, Callable, List, Optional, Protocol, Tuple +from langchain_core._api import deprecated from langchain_core.callbacks import Callbacks from langchain_core.documents import Document from pydantic import ConfigDict @@ -121,6 +122,15 @@ async def acollapse_docs( return Document(page_content=result, metadata=combined_metadata) +@deprecated( + since="0.3.1", + removal="1.0", + message=( + "This class is deprecated. Please see the migration guide here for " + "a recommended replacement: " + "https://python.langchain.com/docs/versions/migrating_chains/map_reduce_chain/" + ), +) class ReduceDocumentsChain(BaseCombineDocumentsChain): """Combine documents by recursively reducing them. diff --git a/libs/langchain/langchain/chains/combine_documents/refine.py b/libs/langchain/langchain/chains/combine_documents/refine.py index 7129ac147dbb1..27bd8c44f1b65 100644 --- a/libs/langchain/langchain/chains/combine_documents/refine.py +++ b/libs/langchain/langchain/chains/combine_documents/refine.py @@ -4,6 +4,7 @@ from typing import Any, Dict, List, Tuple +from langchain_core._api import deprecated from langchain_core.callbacks import Callbacks from langchain_core.documents import Document from langchain_core.prompts import BasePromptTemplate, format_document @@ -20,6 +21,15 @@ def _get_default_document_prompt() -> PromptTemplate: return PromptTemplate(input_variables=["page_content"], template="{page_content}") +@deprecated( + since="0.3.1", + removal="1.0", + message=( + "This class is deprecated. Please see the migration guide here for " + "a recommended replacement: " + "https://python.langchain.com/docs/versions/migrating_chains/refine_docs_chain/" # noqa: E501 + ), +) class RefineDocumentsChain(BaseCombineDocumentsChain): """Combine documents by doing a first pass and then refining on more documents.