Skip to content

Commit 4af5bbb

Browse files
authored
feat: add DeprecationWarning for PaLM2TextEmbeddingGenerator (#1018)
* feat: add DeprecationWarning for PaLM2TextEmbeddingGenerator * fix wording * fix wording * use typing_extensions instead
1 parent ef76f13 commit 4af5bbb

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

bigframes/exceptions.py

+4
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,7 @@ class AmbiguousWindowWarning(Warning):
6969

7070
class UnknownDataTypeWarning(Warning):
7171
"""Data type is unknown."""
72+
73+
74+
class ApiDeprecationWarning(FutureWarning):
75+
"""The API has been deprecated."""

bigframes/ml/llm.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
import bigframes_vendored.constants as constants
2323
from google.cloud import bigquery
24+
import typing_extensions
2425

2526
import bigframes
26-
from bigframes import clients
27+
from bigframes import clients, exceptions
2728
from bigframes.core import blocks, log_adapter
2829
from bigframes.ml import base, core, globals, utils
2930
import bigframes.pandas as bpd
@@ -403,12 +404,16 @@ def to_gbq(self, model_name: str, replace: bool = False) -> PaLM2TextGenerator:
403404
return new_model.session.read_gbq_model(model_name)
404405

405406

407+
@typing_extensions.deprecated(
408+
"PaLM2TextEmbeddingGenerator has been deprecated. Use TextEmbeddingGenerator(https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.TextEmbeddingGenerator) instead. ",
409+
category=exceptions.ApiDeprecationWarning,
410+
)
406411
@log_adapter.class_logger
407412
class PaLM2TextEmbeddingGenerator(base.BaseEstimator):
408413
"""PaLM2 text embedding generator LLM model.
409414
410415
.. note::
411-
Models in this class are outdated and going to be deprecated. To use the most updated text embedding models, go to the TextEmbeddingGenerator class.
416+
PaLM2TextEmbeddingGenerator has been deprecated. Use TextEmbeddingGenerator(https://cloud.google.com/python/docs/reference/bigframes/latest/bigframes.ml.llm.TextEmbeddingGenerator) instead.
412417
413418
414419
Args:

tests/system/small/ml/test_llm.py

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import pytest
1616

17+
from bigframes import exceptions
1718
from bigframes.ml import llm
1819
import bigframes.pandas as bpd
1920
from tests.system import utils
@@ -447,3 +448,11 @@ def test_llm_gemini_pro_score_params(llm_fine_tune_df_default_index):
447448
],
448449
index=6,
449450
)
451+
452+
453+
def test_palm2_text_embedding_deprecated():
454+
with pytest.warns(exceptions.ApiDeprecationWarning):
455+
try:
456+
llm.PaLM2TextEmbeddingGenerator()
457+
except (Exception):
458+
pass

0 commit comments

Comments
 (0)