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

#7932

Co-authored-by: Leonid Kuligin <kuligin@google.com>
This commit is contained in:
Leonid Kuligin 2023-08-03 22:28:42 +02:00 committed by GitHub
parent 814faa9de5
commit 2928a1a3c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -111,7 +111,7 @@ class ChatVertexAI(_VertexAICommon, BaseChatModel):
values["client"] = ChatModel.from_pretrained(values["model_name"]) values["client"] = ChatModel.from_pretrained(values["model_name"])
except ImportError: except ImportError:
raise_vertex_import_error() raise_vertex_import_error(minimum_expected_version="1.28.0")
return values return values
def _generate( def _generate(

View File

@ -5,15 +5,17 @@ if TYPE_CHECKING:
from google.auth.credentials import Credentials 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. """Raise ImportError related to Vertex SDK being not available.
Args:
minimum_expected_version: The lowest expected version of the SDK.
Raises: Raises:
ImportError: an ImportError that mentions a required version of the SDK. ImportError: an ImportError that mentions a required version of the SDK.
""" """
sdk = "'google-cloud-aiplatform>=1.26.1'"
raise ImportError( 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}"
) )