Skip to content

Commit 9b0beae

Browse files
sararobcopybara-github
authored andcommitted
docs: add deprecation notice to readme for Generative AI submodules: vertexai.generative_models, vertexai.language_models, vertexai.vision_models, vertexai.tuning, vertexai.caching
PiperOrigin-RevId: 775007033
1 parent 9a0eec6 commit 9b0beae

File tree

7 files changed

+96
-0
lines changed

7 files changed

+96
-0
lines changed

README.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Vertex AI SDK for Python
22
=================================================
33

4+
.. note::
5+
6+
The following Generative AI modules in the Vertex AI SDK are deprecated as of June 24, 2025 and will be removed on June 24, 2026:
7+
`vertexai.generative_models`, `vertexai.language_models`, `vertexai.vision_models`, `vertexai.tuning`, `vertexai.batch_prediction`, `vertexai.caching`. Please use the
8+
[Google Gen AI SDK](https://pypi.org/project/google-genai/) to access these features. See
9+
[the migration guide](https://cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk) for details.
10+
You can continue using all other Vertex AI SDK modules, as they are the recommended way to use the API.
11+
12+
413
|GA| |pypi| |versions| |unit-tests| |system-tests| |sample-tests|
514

615
`Vertex AI`_: Google Vertex AI is an integrated suite of machine learning tools and services for building and using ML models with AutoML or custom code. It offers both novices and experts the best workbench for the entire machine learning development lifecycle.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import functools
16+
from typing import Any, Callable, Optional
17+
import warnings
18+
19+
BASE_WARNING_MESSAGE = (
20+
"This feature is deprecated as of June 24, 2025 and will be removed on June"
21+
" 24, 2026. For details, see"
22+
" https://cloud.google.com/vertex-ai/generative-ai/docs/deprecations/genai-vertexai-sdk."
23+
)
24+
25+
26+
class DeprecationWarning(Warning):
27+
"""A warning that a feature is deprecated."""
28+
29+
30+
def genai_class_deprecation_warning(
31+
message: Optional[str] = BASE_WARNING_MESSAGE,
32+
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
33+
"""Deprecation warning decorator."""
34+
35+
def decorator(cls) -> Any:
36+
37+
original_class_init = cls.__init__
38+
39+
@functools.wraps(original_class_init)
40+
def wrapper(self, *args: Any, **kwargs: Any) -> Any:
41+
warnings.warn(
42+
message=message,
43+
category=DeprecationWarning,
44+
stacklevel=2,
45+
)
46+
original_class_init(self, *args, **kwargs)
47+
48+
cls.__init__ = wrapper
49+
return cls
50+
51+
return decorator

vertexai/caching/_caching.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
ContentsType,
5050
)
5151
from google.protobuf import field_mask_pb2
52+
from vertexai._utils import deprecation_warning
5253

5354

5455
def _prepare_create_request(
@@ -127,6 +128,7 @@ def _prepare_get_cached_content_request(name: str) -> GetCachedContentRequest:
127128
return types_v1.GetCachedContentRequest(name=name)
128129

129130

131+
@deprecation_warning.genai_class_deprecation_warning()
130132
class CachedContent(aiplatform_base._VertexAiResourceNounPlus):
131133
"""A cached content resource."""
132134

vertexai/generative_models/_generative_models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
from google.protobuf import field_mask_pb2
6464
import warnings
6565

66+
from vertexai._utils import deprecation_warning
67+
6668
if TYPE_CHECKING:
6769
from vertexai.caching import CachedContent
6870

@@ -3406,6 +3408,7 @@ def respond_to_model_response(
34063408
return function_response_content
34073409

34083410

3411+
@deprecation_warning.genai_class_deprecation_warning()
34093412
class GenerativeModel(_GenerativeModel):
34103413
__module__ = "vertexai.generative_models"
34113414

vertexai/language_models/_language_models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
from vertexai.language_models import (
4343
_evaluatable_language_models,
4444
)
45+
from vertexai._utils import deprecation_warning
46+
4547

4648
try:
4749
import pandas
@@ -1157,6 +1159,7 @@ def _to_grounding_source_dict(self) -> Dict[str, Any]:
11571159
}
11581160

11591161

1162+
@deprecation_warning.genai_class_deprecation_warning()
11601163
@dataclasses.dataclass
11611164
class GroundingSource:
11621165

@@ -1236,6 +1239,7 @@ def __init__(self, response: Optional[Dict[str, Any]] = {}):
12361239
self.search_queries = response.get("searchQueries", [])
12371240

12381241

1242+
@deprecation_warning.genai_class_deprecation_warning()
12391243
@dataclasses.dataclass
12401244
class TextGenerationResponse:
12411245
"""TextGenerationResponse represents a response of a language model.
@@ -1950,6 +1954,7 @@ def batch_predict(
19501954
)
19511955

19521956

1957+
@deprecation_warning.genai_class_deprecation_warning()
19531958
class TextGenerationModel(
19541959
_TextGenerationModel,
19551960
_TunableTextModelMixin,
@@ -2070,6 +2075,7 @@ def send_message(
20702075
return response_obj
20712076

20722077

2078+
@deprecation_warning.genai_class_deprecation_warning()
20732079
@dataclasses.dataclass
20742080
class TextEmbeddingInput:
20752081
"""Structural text embedding input.
@@ -2422,6 +2428,7 @@ class _TunableTextEmbeddingModelMixin(_PreviewTunableTextEmbeddingModelMixin):
24222428
pass
24232429

24242430

2431+
@deprecation_warning.genai_class_deprecation_warning()
24252432
class TextEmbeddingModel(
24262433
_TextEmbeddingModel,
24272434
_ModelWithBatchPredict,
@@ -2451,6 +2458,7 @@ class TextEmbeddingStatistics:
24512458
truncated: bool
24522459

24532460

2461+
@deprecation_warning.genai_class_deprecation_warning()
24542462
@dataclasses.dataclass
24552463
class TextEmbedding:
24562464
"""Text embedding vector and statistics."""
@@ -2492,6 +2500,7 @@ def _parse_text_embedding_response(
24922500
return cls(values=prediction, _prediction_response=prediction_response)
24932501

24942502

2503+
@deprecation_warning.genai_class_deprecation_warning()
24952504
@dataclasses.dataclass
24962505
class InputOutputTextPair:
24972506
"""InputOutputTextPair represents a pair of input and output texts."""
@@ -2502,6 +2511,7 @@ class InputOutputTextPair:
25022511
output_text: str
25032512

25042513

2514+
@deprecation_warning.genai_class_deprecation_warning()
25052515
@dataclasses.dataclass
25062516
class ChatMessage:
25072517
"""A chat message.
@@ -2562,6 +2572,7 @@ def start_chat(
25622572
)
25632573

25642574

2575+
@deprecation_warning.genai_class_deprecation_warning()
25652576
class ChatModel(_ChatModelBase, _TunableChatModelMixin, _RlhfTunableModelMixin):
25662577
"""ChatModel represents a language model that is capable of chat.
25672578
@@ -2638,6 +2649,7 @@ def start_chat(
26382649
)
26392650

26402651

2652+
@deprecation_warning.genai_class_deprecation_warning()
26412653
class CodeChatModel(_ChatModelBase, _TunableChatModelMixin):
26422654
"""CodeChatModel represents a model that is capable of completing code.
26432655
@@ -3255,6 +3267,7 @@ class _PreviewCodeChatSession(_ChatSessionBaseWithCountTokensMixin):
32553267
__module__ = "vertexai.preview.language_models"
32563268

32573269

3270+
@deprecation_warning.genai_class_deprecation_warning()
32583271
class ChatSession(_ChatSessionBase):
32593272
"""ChatSession represents a chat session with a language model.
32603273
@@ -3288,6 +3301,7 @@ def __init__(
32883301
)
32893302

32903303

3304+
@deprecation_warning.genai_class_deprecation_warning()
32913305
class CodeChatSession(_ChatSessionBase):
32923306
"""CodeChatSession represents a chat session with code chat language model.
32933307
@@ -3720,6 +3734,7 @@ def count_tokens(
37203734
)
37213735

37223736

3737+
@deprecation_warning.genai_class_deprecation_warning()
37233738
class CodeGenerationModel(
37243739
_CodeGenerationModel,
37253740
_TunableTextModelMixin,

vertexai/tuning/_tuning.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939

4040
from google.rpc import status_pb2 # type: ignore
4141

42+
from vertexai._utils import deprecation_warning
43+
4244

4345
_LOGGER = aiplatform_base.Logger(__name__)
4446

@@ -52,6 +54,7 @@ class TuningJobClientWithOverride(aiplatform_utils.ClientWithOverride):
5254
)
5355

5456

57+
@deprecation_warning.genai_class_deprecation_warning()
5558
class TuningJob(aiplatform_base._VertexAiResourceNounPlus):
5659
"""Represents a TuningJob that runs with Google owned models."""
5760

vertexai/vision_models/_vision_models.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
from google.cloud.aiplatform import initializer as aiplatform_initializer
3131
from vertexai._model_garden import _model_garden_models
32+
from vertexai._utils import deprecation_warning
3233

3334
# pylint: disable=g-import-not-at-top
3435
try:
@@ -129,6 +130,7 @@ class SubjectImageConfig:
129130
]
130131

131132

133+
@deprecation_warning.genai_class_deprecation_warning()
132134
class Image:
133135
"""Image."""
134136

@@ -467,6 +469,7 @@ def __init__(
467469
)
468470

469471

472+
@deprecation_warning.genai_class_deprecation_warning()
470473
class Video:
471474
"""Video."""
472475

@@ -572,6 +575,7 @@ def _as_base64_string(self) -> str:
572575
return base64.b64encode(self._video_bytes).decode("ascii")
573576

574577

578+
@deprecation_warning.genai_class_deprecation_warning()
575579
class VideoSegmentConfig:
576580
"""The specific video segments (in seconds) the embeddings are generated for."""
577581

@@ -599,6 +603,7 @@ def __init__(
599603
self.interval_sec = interval_sec
600604

601605

606+
@deprecation_warning.genai_class_deprecation_warning()
602607
class VideoEmbedding:
603608
"""Embeddings generated from video with offset times."""
604609

@@ -623,6 +628,7 @@ def __init__(
623628
self.embedding = embedding
624629

625630

631+
@deprecation_warning.genai_class_deprecation_warning()
626632
class ImageGenerationModel(
627633
_model_garden_models._ModelGardenModel # pylint: disable=protected-access
628634
):
@@ -1377,6 +1383,7 @@ def upscale_image(
13771383
)
13781384

13791385

1386+
@deprecation_warning.genai_class_deprecation_warning()
13801387
@dataclasses.dataclass
13811388
class ImageGenerationResponse:
13821389
"""Image generation response.
@@ -1404,6 +1411,7 @@ def __getitem__(self, idx: int) -> "GeneratedImage":
14041411
)
14051412

14061413

1414+
@deprecation_warning.genai_class_deprecation_warning()
14071415
class GeneratedImage(Image):
14081416
"""Generated image."""
14091417

@@ -1475,6 +1483,7 @@ def save(self, location: str, include_generation_parameters: bool = True):
14751483
super().save(location=location)
14761484

14771485

1486+
@deprecation_warning.genai_class_deprecation_warning()
14781487
class ImageCaptioningModel(
14791488
_model_garden_models._ModelGardenModel # pylint: disable=protected-access
14801489
):
@@ -1540,6 +1549,7 @@ def get_captions(
15401549
return response.predictions
15411550

15421551

1552+
@deprecation_warning.genai_class_deprecation_warning()
15431553
class ImageQnAModel(
15441554
_model_garden_models._ModelGardenModel # pylint: disable=protected-access
15451555
):
@@ -1599,6 +1609,7 @@ def ask_question(
15991609
return response.predictions
16001610

16011611

1612+
@deprecation_warning.genai_class_deprecation_warning()
16021613
class MultiModalEmbeddingModel(_model_garden_models._ModelGardenModel):
16031614
"""Generates embedding vectors from images and videos.
16041615
@@ -1724,6 +1735,7 @@ def get_embeddings(
17241735
)
17251736

17261737

1738+
@deprecation_warning.genai_class_deprecation_warning()
17271739
@dataclasses.dataclass
17281740
class MultiModalEmbeddingResponse:
17291741
"""The multimodal embedding response.
@@ -1745,6 +1757,7 @@ class MultiModalEmbeddingResponse:
17451757
text_embedding: Optional[List[float]] = None
17461758

17471759

1760+
@deprecation_warning.genai_class_deprecation_warning()
17481761
class ImageTextModel(ImageCaptioningModel, ImageQnAModel):
17491762
"""Generates text from images.
17501763

0 commit comments

Comments
 (0)