From 85a4594ed7dbde9d257e230d5d789b68c42421cf Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Tue, 9 Jan 2024 20:36:16 -0800 Subject: [PATCH] community[patch]: more deprecations (#15782) --- .../chat_models/azure_openai.py | 9 +----- .../langchain_community/chat_models/openai.py | 11 +------ .../chat_models/vertexai.py | 6 ++++ .../embeddings/azure_openai.py | 4 ++- .../langchain_community/embeddings/openai.py | 2 +- .../embeddings/vertexai.py | 6 ++++ .../langchain_community/llms/google_palm.py | 2 +- .../langchain_community/llms/openai.py | 31 ++----------------- .../langchain_community/llms/vertexai.py | 11 +++++++ libs/community/poetry.lock | 4 +-- libs/community/pyproject.toml | 2 +- 11 files changed, 36 insertions(+), 52 deletions(-) diff --git a/libs/community/langchain_community/chat_models/azure_openai.py b/libs/community/langchain_community/chat_models/azure_openai.py index 5f9e8d1b711..0db36ad947f 100644 --- a/libs/community/langchain_community/chat_models/azure_openai.py +++ b/libs/community/langchain_community/chat_models/azure_openai.py @@ -20,14 +20,7 @@ logger = logging.getLogger(__name__) @deprecated( since="0.0.10", removal="0.2.0", - message=( - "The class langchain_community.chat_models.azure_openai.AzureChatOpenAI was " - "deprecated in langchain-community 0.0.10 and will be removed in " - "langchain-community 0.2.0. An updated version of the class lives in the " - "langchain-openai package and should be used instead. To use it run " - "`pip install -U langchain-openai` and import as " - "`from langchain_openai import AzureChatOpenAI`." - ), + alternative_import="langchain_openai.AzureChatOpenAI", ) class AzureChatOpenAI(ChatOpenAI): """`Azure OpenAI` Chat Completion API. diff --git a/libs/community/langchain_community/chat_models/openai.py b/libs/community/langchain_community/chat_models/openai.py index 0b043419a97..568767662c9 100644 --- a/libs/community/langchain_community/chat_models/openai.py +++ b/libs/community/langchain_community/chat_models/openai.py @@ -145,16 +145,7 @@ def _convert_delta_to_message_chunk( @deprecated( - since="0.0.10", - removal="0.2.0", - message=( - "The class langchain_community.chat_models.openai.ChatOpenAI was " - "deprecated in langchain-community 0.0.10 and will be removed in " - "langchain-community 0.2.0. An updated version of the class lives in the " - "langchain-openai package and should be used instead. To use it run " - "`pip install -U langchain-openai` and import as " - "`from langchain_openai import ChatOpenAI`." - ), + since="0.0.10", removal="0.2.0", alternative_import="langchain_openai.ChatOpenAI" ) class ChatOpenAI(BaseChatModel): """`OpenAI` Chat large language models API. diff --git a/libs/community/langchain_community/chat_models/vertexai.py b/libs/community/langchain_community/chat_models/vertexai.py index 32b126ef445..cecd63ac41f 100644 --- a/libs/community/langchain_community/chat_models/vertexai.py +++ b/libs/community/langchain_community/chat_models/vertexai.py @@ -9,6 +9,7 @@ from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Union, ca from urllib.parse import urlparse import requests +from langchain_core._api.deprecation import deprecated from langchain_core.callbacks import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, @@ -203,6 +204,11 @@ def _get_question(messages: List[BaseMessage]) -> HumanMessage: return question +@deprecated( + since="0.0.12", + removal="0.2.0", + alternative_import="langchain_google_vertexai.ChatVertexAI", +) class ChatVertexAI(_VertexAICommon, BaseChatModel): """`Vertex AI` Chat large language models API.""" diff --git a/libs/community/langchain_community/embeddings/azure_openai.py b/libs/community/langchain_community/embeddings/azure_openai.py index da5ad573bb2..ec90c767148 100644 --- a/libs/community/langchain_community/embeddings/azure_openai.py +++ b/libs/community/langchain_community/embeddings/azure_openai.py @@ -14,7 +14,9 @@ from langchain_community.utils.openai import is_openai_v1 @deprecated( - since="0.1.0", removal="0.2.0", alternative="langchain_openai.AzureOpenAIEmbeddings" + since="0.1.0", + removal="0.2.0", + alternative_import="langchain_openai.AzureOpenAIEmbeddings", ) class AzureOpenAIEmbeddings(OpenAIEmbeddings): """`Azure OpenAI` Embeddings API.""" diff --git a/libs/community/langchain_community/embeddings/openai.py b/libs/community/langchain_community/embeddings/openai.py index 8fc66519db7..a459a872c07 100644 --- a/libs/community/langchain_community/embeddings/openai.py +++ b/libs/community/langchain_community/embeddings/openai.py @@ -141,7 +141,7 @@ async def async_embed_with_retry(embeddings: OpenAIEmbeddings, **kwargs: Any) -> @deprecated( since="0.1.0", removal="0.2.0", - alternative="langchain_openai.OpenAIEmbeddings", + alternative_import="langchain_openai.OpenAIEmbeddings", ) class OpenAIEmbeddings(BaseModel, Embeddings): """OpenAI embedding models. diff --git a/libs/community/langchain_community/embeddings/vertexai.py b/libs/community/langchain_community/embeddings/vertexai.py index 821708a7825..e0f0834587f 100644 --- a/libs/community/langchain_community/embeddings/vertexai.py +++ b/libs/community/langchain_community/embeddings/vertexai.py @@ -5,6 +5,7 @@ import threading from concurrent.futures import ThreadPoolExecutor, wait from typing import Any, Dict, List, Literal, Optional, Tuple +from langchain_core._api.deprecation import deprecated from langchain_core.embeddings import Embeddings from langchain_core.language_models.llms import create_base_retry_decorator from langchain_core.pydantic_v1 import root_validator @@ -19,6 +20,11 @@ _MAX_BATCH_SIZE = 250 _MIN_BATCH_SIZE = 5 +@deprecated( + since="0.0.12", + removal="0.2.0", + alternative_import="langchain_google_vertexai.VertexAIEmbeddings", +) class VertexAIEmbeddings(_VertexAICommon, Embeddings): """Google Cloud VertexAI embedding models.""" diff --git a/libs/community/langchain_community/llms/google_palm.py b/libs/community/langchain_community/llms/google_palm.py index 8f4f1614e2c..08946bbbfba 100644 --- a/libs/community/langchain_community/llms/google_palm.py +++ b/libs/community/langchain_community/llms/google_palm.py @@ -59,7 +59,7 @@ def _strip_erroneous_leading_spaces(text: str) -> str: return text -@deprecated("0.0.351", alternative="langchain_google_genai.GoogleGenerativeAI") +@deprecated("0.0.351", alternative_import="langchain_google_genai.GoogleGenerativeAI") class GooglePalm(BaseLLM, BaseModel): """ DEPRECATED: Use `langchain_google_genai.GoogleGenerativeAI` instead. diff --git a/libs/community/langchain_community/llms/openai.py b/libs/community/langchain_community/llms/openai.py index ca6338bd79e..d9eb6b5d367 100644 --- a/libs/community/langchain_community/llms/openai.py +++ b/libs/community/langchain_community/llms/openai.py @@ -726,16 +726,7 @@ class BaseOpenAI(BaseLLM): @deprecated( - since="0.0.10", - removal="0.2.0", - message=( - "The class langchain_community.llms.openai.OpenAI was " - "deprecated in langchain-community 0.0.10 and will be removed in " - "langchain-community 0.2.0. An updated version of the class lives in the " - "langchain-openai package and should be used instead. To use it run " - "`pip install -U langchain-openai` and import as " - "`from langchain_openai import OpenAI`." - ), + since="0.0.10", removal="0.2.0", alternative_import="langchain_openai.OpenAI" ) class OpenAI(BaseOpenAI): """OpenAI large language models. @@ -764,16 +755,7 @@ class OpenAI(BaseOpenAI): @deprecated( - since="0.0.10", - removal="0.2.0", - message=( - "The class langchain_community.llms.openai.AzureOpenAI was " - "deprecated in langchain-community 0.0.10 and will be removed in " - "langchain-community 0.2.0. An updated version of the class lives in the " - "langchain-openai package and should be used instead. To use it run " - "`pip install -U langchain-openai` and import as " - "`from langchain_openai import AzureOpenAI`." - ), + since="0.0.10", removal="0.2.0", alternative_import="langchain_openai.AzureOpenAI" ) class AzureOpenAI(BaseOpenAI): """Azure-specific OpenAI large language models. @@ -981,14 +963,7 @@ class AzureOpenAI(BaseOpenAI): @deprecated( since="0.0.1", removal="0.2.0", - message=( - "The class langchain_community.llms.openai.OpenAIChat was " - "deprecated in langchain-community 0.0.1 and will be removed in " - "langchain-community 0.2.0. An updated version of the class lives in the " - "langchain-openai package and should be used instead. To use it run " - "`pip install -U langchain-openai` and import as " - "`from langchain_openai import ChatOpenAI`." - ), + alternative_import="langchain_openai.ChatOpenAI", ) class OpenAIChat(BaseLLM): """OpenAI Chat large language models. diff --git a/libs/community/langchain_community/llms/vertexai.py b/libs/community/langchain_community/llms/vertexai.py index 22bace0d7bc..3833bbd785c 100644 --- a/libs/community/langchain_community/llms/vertexai.py +++ b/libs/community/langchain_community/llms/vertexai.py @@ -3,6 +3,7 @@ from __future__ import annotations from concurrent.futures import Executor, ThreadPoolExecutor from typing import TYPE_CHECKING, Any, ClassVar, Dict, Iterator, List, Optional, Union +from langchain_core._api.deprecation import deprecated from langchain_core.callbacks.manager import ( AsyncCallbackManagerForLLMRun, CallbackManagerForLLMRun, @@ -200,6 +201,11 @@ class _VertexAICommon(_VertexAIBase): return params +@deprecated( + since="0.0.12", + removal="0.2.0", + alternative_import="langchain_google_vertexai.VertexAI", +) class VertexAI(_VertexAICommon, BaseLLM): """Google Vertex AI large language models.""" @@ -385,6 +391,11 @@ class VertexAI(_VertexAICommon, BaseLLM): ) +@deprecated( + since="0.0.12", + removal="0.2.0", + alternative_import="langchain_google_vertexai.VertexAIModelGarden", +) class VertexAIModelGarden(_VertexAIBase, BaseLLM): """Large language models served from Vertex AI Model Garden.""" diff --git a/libs/community/poetry.lock b/libs/community/poetry.lock index 1f783bb3efd..db439c02327 100644 --- a/libs/community/poetry.lock +++ b/libs/community/poetry.lock @@ -3881,7 +3881,7 @@ files = [ [[package]] name = "langchain-core" -version = "0.1.8" +version = "0.1.9" description = "Building applications with LLMs through composability" optional = false python-versions = ">=3.8.1,<4.0" @@ -9144,4 +9144,4 @@ extended-testing = ["aiosqlite", "aleph-alpha-client", "anthropic", "arxiv", "as [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "a3765004062afc80420d49d782e3e023aec1707bf35ae2f808d88a1cac53b694" +content-hash = "edadd024e8b2b4a817a90336013a1d92be102d03d4c41fbf5ac137f16d97fdfb" diff --git a/libs/community/pyproject.toml b/libs/community/pyproject.toml index e47a39b2ffa..cbb879676dd 100644 --- a/libs/community/pyproject.toml +++ b/libs/community/pyproject.toml @@ -9,7 +9,7 @@ repository = "https://github.com/langchain-ai/langchain" [tool.poetry.dependencies] python = ">=3.8.1,<4.0" -langchain-core = ">=0.1.8,<0.2" +langchain-core = ">=0.1.9,<0.2" SQLAlchemy = ">=1.4,<3" requests = "^2" PyYAML = ">=5.3"