Skip to content

Commit

Permalink
chore: Clarify that api keys are only supported in preview namespace
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 695810159
  • Loading branch information
matthew29tang authored and copybara-github committed Nov 12, 2024
1 parent 1fca9c0 commit cd72694
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions vertexai/generative_models/_generative_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3152,6 +3152,15 @@ class GenerativeModel(_GenerativeModel):
def _prediction_client(self) -> prediction_service_v1.PredictionServiceClient:
# Switch to @functools.cached_property once its available.
if not getattr(self, "_prediction_client_value", None):
if (
aiplatform_initializer.global_config.api_key
and not aiplatform_initializer.global_config.project
):
raise ValueError(
"Api keys are only supported with the preview namespace. "
"Import the preview namespace instead:\n"
"from vertexai.preview import generative_models"
)
self._prediction_client_value = (
aiplatform_initializer.global_config.create_client(
client_class=prediction_service_v1.PredictionServiceClient,
Expand All @@ -3167,6 +3176,15 @@ def _prediction_async_client(
) -> prediction_service_v1.PredictionServiceAsyncClient:
# Switch to @functools.cached_property once its available.
if not getattr(self, "_prediction_async_client_value", None):
if (
aiplatform_initializer.global_config.api_key
and not aiplatform_initializer.global_config.project
):
raise ValueError(
"Api keys are only supported with the preview namespace. "
"Import the preview namespace instead:\n"
"from vertexai.preview import generative_models"
)
self._prediction_async_client_value = (
aiplatform_initializer.global_config.create_client(
client_class=prediction_service_v1.PredictionServiceAsyncClient,
Expand Down

0 comments on commit cd72694

Please sign in to comment.