Skip to content

Commit f5d91f3

Browse files
authored
chore: change error to warning for gemini models (#1715)
* chore: change error to warning for gemini models * remove model
1 parent 90e277e commit f5d91f3

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

bigframes/ml/llm.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
_GEMINI_2_FLASH_EXP_ENDPOINT = "gemini-2.0-flash-exp"
5454
_GEMINI_2_FLASH_001_ENDPOINT = "gemini-2.0-flash-001"
5555
_GEMINI_2_FLASH_LITE_001_ENDPOINT = "gemini-2.0-flash-lite-001"
56+
_GEMINI_2P5_PRO_PREVIEW_ENDPOINT = "gemini-2.5-pro-preview-05-06"
5657
_GEMINI_ENDPOINTS = (
5758
_GEMINI_1P5_PRO_PREVIEW_ENDPOINT,
5859
_GEMINI_1P5_PRO_FLASH_PREVIEW_ENDPOINT,
@@ -104,6 +105,12 @@
104105

105106
_REMOVE_DEFAULT_MODEL_WARNING = "Since upgrading the default model can cause unintended breakages, the default model will be removed in BigFrames 3.0. Please supply an explicit model to avoid this message."
106107

108+
_GEMINI_MULTIMODAL_MODEL_NOT_SUPPORTED_WARNING = (
109+
"The model '{model_name}' may not be fully supported by GeminiTextGenerator for Multimodal prompts. "
110+
"GeminiTextGenerator is known to support the following models for Multimodal prompts: {known_models}. "
111+
"If you proceed with '{model_name}', it might not work as expected or could lead to errors with multimodal inputs."
112+
)
113+
107114

108115
@log_adapter.class_logger
109116
class TextEmbeddingGenerator(base.RetriableRemotePredictor):
@@ -540,9 +547,10 @@ def fit(
540547
GeminiTextGenerator: Fitted estimator.
541548
"""
542549
if self.model_name not in _GEMINI_FINE_TUNE_SCORE_ENDPOINTS:
543-
raise NotImplementedError(
550+
msg = exceptions.format_message(
544551
"fit() only supports gemini-1.5-pro-002, or gemini-1.5-flash-002 model."
545552
)
553+
warnings.warn(msg)
546554

547555
X, y = utils.batch_convert_to_dataframe(X, y)
548556

@@ -651,9 +659,13 @@ def predict(
651659

652660
if prompt:
653661
if self.model_name not in _GEMINI_MULTIMODAL_ENDPOINTS:
654-
raise NotImplementedError(
655-
f"GeminiTextGenerator only supports model_name {', '.join(_GEMINI_MULTIMODAL_ENDPOINTS)} for Multimodal prompt."
662+
msg = exceptions.format_message(
663+
_GEMINI_MULTIMODAL_MODEL_NOT_SUPPORTED_WARNING.format(
664+
model_name=self.model_name,
665+
known_models=", ".join(_GEMINI_MULTIMODAL_ENDPOINTS),
666+
)
656667
)
668+
warnings.warn(msg)
657669

658670
df_prompt = X[[X.columns[0]]].rename(
659671
columns={X.columns[0]: "bigframes_placeholder_col"}
@@ -750,9 +762,10 @@ def score(
750762
raise RuntimeError("A model must be fitted before score")
751763

752764
if self.model_name not in _GEMINI_FINE_TUNE_SCORE_ENDPOINTS:
753-
raise NotImplementedError(
765+
msg = exceptions.format_message(
754766
"score() only supports gemini-1.5-pro-002, gemini-1.5-flash-2, gemini-2.0-flash-001, and gemini-2.0-flash-lite-001 model."
755767
)
768+
warnings.warn(msg)
756769

757770
X, y = utils.batch_convert_to_dataframe(X, y, session=self._bqml_model.session)
758771

bigframes/ml/loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
llm._GEMINI_2_FLASH_EXP_ENDPOINT: llm.GeminiTextGenerator,
6767
llm._GEMINI_2_FLASH_001_ENDPOINT: llm.GeminiTextGenerator,
6868
llm._GEMINI_2_FLASH_LITE_001_ENDPOINT: llm.GeminiTextGenerator,
69+
llm._GEMINI_2P5_PRO_PREVIEW_ENDPOINT: llm.GeminiTextGenerator,
6970
llm._CLAUDE_3_HAIKU_ENDPOINT: llm.Claude3TextGenerator,
7071
llm._CLAUDE_3_SONNET_ENDPOINT: llm.Claude3TextGenerator,
7172
llm._CLAUDE_3_5_SONNET_ENDPOINT: llm.Claude3TextGenerator,

0 commit comments

Comments
 (0)