Skip to content

The agent engineering platform.

added minimum expected version of SDK to the error description (#8712)

Leonid Kuligin2928a1a3c9f9
diff --git a/libs/langchain/langchain/chat_models/vertexai.py b/libs/langchain/langchain/chat_models/vertexai.py
index b50eac264a..d9a08d7f06 100644
--- a/libs/langchain/langchain/chat_models/vertexai.py
+++ b/libs/langchain/langchain/chat_models/vertexai.py
@@ -111,7 +111,7 @@ class ChatVertexAI(_VertexAICommon, BaseChatModel):
values["client"] = ChatModel.from_pretrained(values["model_name"])
except ImportError:
- raise_vertex_import_error()
+ raise_vertex_import_error(minimum_expected_version="1.28.0")
return values
def _generate(
diff --git a/libs/langchain/langchain/utilities/vertexai.py b/libs/langchain/langchain/utilities/vertexai.py
index a934987cd8..95c493585a 100644
--- a/libs/langchain/langchain/utilities/vertexai.py
+++ b/libs/langchain/langchain/utilities/vertexai.py
@@ -5,15 +5,17 @@ if TYPE_CHECKING:
from google.auth.credentials import Credentials
-def raise_vertex_import_error() -> None:
+def raise_vertex_import_error(minimum_expected_version: str = "1.26.1") -> None:
"""Raise ImportError related to Vertex SDK being not available.
+ Args:
+ minimum_expected_version: The lowest expected version of the SDK.
Raises:
ImportError: an ImportError that mentions a required version of the SDK.
"""
- sdk = "'google-cloud-aiplatform>=1.26.1'"
raise ImportError(
- "Could not import VertexAI. Please, install it with " f"pip install {sdk}"
+ "Could not import VertexAI. Please, install it with "
+ f"pip install google-cloud-aiplatform>={minimum_expected_version}"
)