Skip to content

Commit 1021d57

Browse files
authored
feat: add Gemini 2.0 preview text model support (#1209)
* feat: add Gemini 2.0 preview text model support * update docs
1 parent c63e7da commit 1021d57

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

‎bigframes/ml/llm.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
_GEMINI_1P5_PRO_002_ENDPOINT = "gemini-1.5-pro-002"
6464
_GEMINI_1P5_FLASH_001_ENDPOINT = "gemini-1.5-flash-001"
6565
_GEMINI_1P5_FLASH_002_ENDPOINT = "gemini-1.5-flash-002"
66+
_GEMINI_2_FLASH_EXP_ENDPOINT = "gemini-2.0-flash-exp"
6667
_GEMINI_ENDPOINTS = (
6768
_GEMINI_PRO_ENDPOINT,
6869
_GEMINI_1P5_PRO_PREVIEW_ENDPOINT,
@@ -71,6 +72,12 @@
7172
_GEMINI_1P5_PRO_002_ENDPOINT,
7273
_GEMINI_1P5_FLASH_001_ENDPOINT,
7374
_GEMINI_1P5_FLASH_002_ENDPOINT,
75+
_GEMINI_2_FLASH_EXP_ENDPOINT,
76+
)
77+
_GEMINI_PREVIEW_ENDPOINTS = (
78+
_GEMINI_1P5_PRO_PREVIEW_ENDPOINT,
79+
_GEMINI_1P5_PRO_FLASH_PREVIEW_ENDPOINT,
80+
_GEMINI_2_FLASH_EXP_ENDPOINT,
7481
)
7582

7683
_CLAUDE_3_SONNET_ENDPOINT = "claude-3-sonnet"
@@ -757,10 +764,10 @@ class GeminiTextGenerator(base.BaseEstimator):
757764
758765
Args:
759766
model_name (str, Default to "gemini-pro"):
760-
The model for natural language tasks. Accepted values are "gemini-pro", "gemini-1.5-pro-preview-0514", "gemini-1.5-flash-preview-0514", "gemini-1.5-pro-001", "gemini-1.5-pro-002", "gemini-1.5-flash-001" and "gemini-1.5-flash-002". Default to "gemini-pro".
767+
The model for natural language tasks. Accepted values are "gemini-pro", "gemini-1.5-pro-preview-0514", "gemini-1.5-flash-preview-0514", "gemini-1.5-pro-001", "gemini-1.5-pro-002", "gemini-1.5-flash-001", "gemini-1.5-flash-002" and "gemini-2.0-flash-exp". Default to "gemini-pro".
761768
762769
.. note::
763-
"gemini-1.5-pro-preview-0514" and "gemini-1.5-flash-preview-0514" is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
770+
"gemini-2.0-flash-exp", "gemini-1.5-pro-preview-0514" and "gemini-1.5-flash-preview-0514" is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
764771
Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available "as is"
765772
and might have limited support. For more information, see the launch stage descriptions
766773
(https://cloud.google.com/products#product-launch-stages).
@@ -786,11 +793,20 @@ def __init__(
786793
"gemini-1.5-pro-002",
787794
"gemini-1.5-flash-001",
788795
"gemini-1.5-flash-002",
796+
"gemini-2.0-flash-exp",
789797
] = "gemini-pro",
790798
session: Optional[bigframes.Session] = None,
791799
connection_name: Optional[str] = None,
792800
max_iterations: int = 300,
793801
):
802+
if model_name in _GEMINI_PREVIEW_ENDPOINTS:
803+
warnings.warn(
804+
f"""Model {model_name} is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
805+
Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available "as is"
806+
and might have limited support. For more information, see the launch stage descriptions
807+
(https://cloud.google.com/products#product-launch-stages).""",
808+
category=exceptions.PreviewWarning,
809+
)
794810
self.model_name = model_name
795811
self.session = session or bpd.get_global_session()
796812
self.max_iterations = max_iterations

‎bigframes/ml/loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
llm._GEMINI_1P5_PRO_002_ENDPOINT: llm.GeminiTextGenerator,
6868
llm._GEMINI_1P5_FLASH_001_ENDPOINT: llm.GeminiTextGenerator,
6969
llm._GEMINI_1P5_FLASH_002_ENDPOINT: llm.GeminiTextGenerator,
70+
llm._GEMINI_2_FLASH_EXP_ENDPOINT: llm.GeminiTextGenerator,
7071
llm._CLAUDE_3_HAIKU_ENDPOINT: llm.Claude3TextGenerator,
7172
llm._CLAUDE_3_SONNET_ENDPOINT: llm.Claude3TextGenerator,
7273
llm._CLAUDE_3_5_SONNET_ENDPOINT: llm.Claude3TextGenerator,

0 commit comments

Comments
 (0)