Skip to content

Commit

Permalink
feat: add Gemini 2.0 preview text model support (#1209)
Browse files Browse the repository at this point in the history
* feat: add Gemini 2.0 preview text model support

* update docs
  • Loading branch information
GarrettWu authored Dec 11, 2024
1 parent c63e7da commit 1021d57
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions bigframes/ml/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
_GEMINI_1P5_PRO_002_ENDPOINT = "gemini-1.5-pro-002"
_GEMINI_1P5_FLASH_001_ENDPOINT = "gemini-1.5-flash-001"
_GEMINI_1P5_FLASH_002_ENDPOINT = "gemini-1.5-flash-002"
_GEMINI_2_FLASH_EXP_ENDPOINT = "gemini-2.0-flash-exp"
_GEMINI_ENDPOINTS = (
_GEMINI_PRO_ENDPOINT,
_GEMINI_1P5_PRO_PREVIEW_ENDPOINT,
Expand All @@ -71,6 +72,12 @@
_GEMINI_1P5_PRO_002_ENDPOINT,
_GEMINI_1P5_FLASH_001_ENDPOINT,
_GEMINI_1P5_FLASH_002_ENDPOINT,
_GEMINI_2_FLASH_EXP_ENDPOINT,
)
_GEMINI_PREVIEW_ENDPOINTS = (
_GEMINI_1P5_PRO_PREVIEW_ENDPOINT,
_GEMINI_1P5_PRO_FLASH_PREVIEW_ENDPOINT,
_GEMINI_2_FLASH_EXP_ENDPOINT,
)

_CLAUDE_3_SONNET_ENDPOINT = "claude-3-sonnet"
Expand Down Expand Up @@ -757,10 +764,10 @@ class GeminiTextGenerator(base.BaseEstimator):
Args:
model_name (str, Default to "gemini-pro"):
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".
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".
.. note::
"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
"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
Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available "as is"
and might have limited support. For more information, see the launch stage descriptions
(https://cloud.google.com/products#product-launch-stages).
Expand All @@ -786,11 +793,20 @@ def __init__(
"gemini-1.5-pro-002",
"gemini-1.5-flash-001",
"gemini-1.5-flash-002",
"gemini-2.0-flash-exp",
] = "gemini-pro",
session: Optional[bigframes.Session] = None,
connection_name: Optional[str] = None,
max_iterations: int = 300,
):
if model_name in _GEMINI_PREVIEW_ENDPOINTS:
warnings.warn(
f"""Model {model_name} is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
Service Specific Terms(https://cloud.google.com/terms/service-terms#1). Pre-GA products and features are available "as is"
and might have limited support. For more information, see the launch stage descriptions
(https://cloud.google.com/products#product-launch-stages).""",
category=exceptions.PreviewWarning,
)
self.model_name = model_name
self.session = session or bpd.get_global_session()
self.max_iterations = max_iterations
Expand Down
1 change: 1 addition & 0 deletions bigframes/ml/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
llm._GEMINI_1P5_PRO_002_ENDPOINT: llm.GeminiTextGenerator,
llm._GEMINI_1P5_FLASH_001_ENDPOINT: llm.GeminiTextGenerator,
llm._GEMINI_1P5_FLASH_002_ENDPOINT: llm.GeminiTextGenerator,
llm._GEMINI_2_FLASH_EXP_ENDPOINT: llm.GeminiTextGenerator,
llm._CLAUDE_3_HAIKU_ENDPOINT: llm.Claude3TextGenerator,
llm._CLAUDE_3_SONNET_ENDPOINT: llm.Claude3TextGenerator,
llm._CLAUDE_3_5_SONNET_ENDPOINT: llm.Claude3TextGenerator,
Expand Down

0 comments on commit 1021d57

Please sign in to comment.