From e1203786954fd1eaba6f1d43dbc9604f64f3dd12 Mon Sep 17 00:00:00 2001 From: Michael Chin Date: Tue, 28 Jan 2025 06:50:14 -0800 Subject: [PATCH] community: Additional AWS deprecations (#29447) Added deprecation warnings for a few more classes that weremoved to `langchain-aws` package: - [SageMaker Endpoint LLM](https://python.langchain.com/api_reference/aws/retrievers/langchain_aws.retrievers.bedrock.AmazonKnowledgeBasesRetriever.html) - [Amazon Kendra retriever](https://python.langchain.com/api_reference/aws/retrievers/langchain_aws.retrievers.kendra.AmazonKendraRetriever.html) - [Amazon Bedrock Knowledge Bases retriever](https://python.langchain.com/api_reference/aws/retrievers/langchain_aws.retrievers.bedrock.AmazonKnowledgeBasesRetriever.html) --- .../langchain_community/llms/sagemaker_endpoint.py | 6 ++++++ libs/community/langchain_community/retrievers/bedrock.py | 6 ++++++ libs/community/langchain_community/retrievers/kendra.py | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/libs/community/langchain_community/llms/sagemaker_endpoint.py b/libs/community/langchain_community/llms/sagemaker_endpoint.py index db86beb9e0f..e78d2654410 100644 --- a/libs/community/langchain_community/llms/sagemaker_endpoint.py +++ b/libs/community/langchain_community/llms/sagemaker_endpoint.py @@ -5,6 +5,7 @@ import json from abc import abstractmethod from typing import Any, Dict, Generic, Iterator, List, Mapping, Optional, TypeVar, Union +from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.utils import pre_init @@ -124,6 +125,11 @@ class LLMContentHandler(ContentHandlerBase[str, str]): """Content handler for LLM class.""" +@deprecated( + since="0.3.16", + removal="1.0", + alternative_import="langchain_aws.llms.SagemakerEndpoint", +) class SagemakerEndpoint(LLM): """Sagemaker Inference Endpoint models. diff --git a/libs/community/langchain_community/retrievers/bedrock.py b/libs/community/langchain_community/retrievers/bedrock.py index 6415bc97678..d7fe03ad2c3 100644 --- a/libs/community/langchain_community/retrievers/bedrock.py +++ b/libs/community/langchain_community/retrievers/bedrock.py @@ -1,5 +1,6 @@ from typing import Any, Dict, List, Optional +from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import CallbackManagerForRetrieverRun from langchain_core.documents import Document from langchain_core.retrievers import BaseRetriever @@ -18,6 +19,11 @@ class RetrievalConfig(BaseModel, extra="allow"): # type: ignore[call-arg] vectorSearchConfiguration: VectorSearchConfig +@deprecated( + since="0.3.16", + removal="1.0", + alternative_import="langchain_aws.AmazonKnowledgeBasesRetriever", +) class AmazonKnowledgeBasesRetriever(BaseRetriever): """Amazon Bedrock Knowledge Bases retriever. diff --git a/libs/community/langchain_community/retrievers/kendra.py b/libs/community/langchain_community/retrievers/kendra.py index d674c368663..1b7cc5fbcd0 100644 --- a/libs/community/langchain_community/retrievers/kendra.py +++ b/libs/community/langchain_community/retrievers/kendra.py @@ -11,6 +11,7 @@ from typing import ( Union, ) +from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import CallbackManagerForRetrieverRun from langchain_core.documents import Document from langchain_core.retrievers import BaseRetriever @@ -323,6 +324,11 @@ KENDRA_CONFIDENCE_MAPPING = { } +@deprecated( + since="0.3.16", + removal="1.0", + alternative_import="langchain_aws.AmazonKendraRetriever", +) class AmazonKendraRetriever(BaseRetriever): """`Amazon Kendra Index` retriever.