feat: Add gemini-3-pro-preview (#3950)

* Add gemini-3-pro-preview

Also refactors the tool support check for better forward compatibility.

* Add cassette for Gemini 3 Pro

---------

Co-authored-by: Greyson LaLonde <greyson.r.lalonde@gmail.com>
This commit is contained in:
Mark McDonald
2025-11-25 03:49:29 +08:00
committed by GitHub
parent b759654e7d
commit a978267fa2
7 changed files with 78 additions and 5 deletions

View File

@@ -145,6 +145,7 @@ MODELS = {
"claude-3-haiku-20240307",
],
"gemini": [
"gemini/gemini-3-pro-preview",
"gemini/gemini-1.5-flash",
"gemini/gemini-1.5-pro",
"gemini/gemini-2.0-flash-lite-001",

View File

@@ -179,6 +179,7 @@ LLM_CONTEXT_WINDOW_SIZES: Final[dict[str, int]] = {
"o3-mini": 200000,
"o4-mini": 200000,
# gemini
"gemini-3-pro-preview": 1048576,
"gemini-2.0-flash": 1048576,
"gemini-2.0-flash-thinking-exp-01-21": 32768,
"gemini-2.0-flash-lite-001": 1048576,

View File

@@ -235,6 +235,7 @@ ANTHROPIC_MODELS: list[AnthropicModels] = [
]
GeminiModels: TypeAlias = Literal[
"gemini-3-pro-preview",
"gemini-2.5-pro",
"gemini-2.5-pro-preview-03-25",
"gemini-2.5-pro-preview-05-06",
@@ -287,6 +288,7 @@ GeminiModels: TypeAlias = Literal[
"learnlm-2.0-flash-experimental",
]
GEMINI_MODELS: list[GeminiModels] = [
"gemini-3-pro-preview",
"gemini-2.5-pro",
"gemini-2.5-pro-preview-03-25",
"gemini-2.5-pro-preview-05-06",

View File

@@ -1,5 +1,6 @@
import logging
import os
import re
from typing import Any, cast
from pydantic import BaseModel
@@ -100,9 +101,8 @@ class GeminiCompletion(BaseLLM):
self.stop_sequences = stop_sequences or []
# Model-specific settings
self.is_gemini_2 = "gemini-2" in model.lower()
self.is_gemini_1_5 = "gemini-1.5" in model.lower()
self.supports_tools = self.is_gemini_1_5 or self.is_gemini_2
version_match = re.search(r"gemini-(\d+(?:\.\d+)?)", model.lower())
self.supports_tools = bool(version_match and float(version_match.group(1)) >= 1.5)
@property
def stop(self) -> list[str]:
@@ -559,6 +559,7 @@ class GeminiCompletion(BaseLLM):
)
context_windows = {
"gemini-3-pro-preview": 1048576, # 1M tokens
"gemini-2.0-flash": 1048576, # 1M tokens
"gemini-2.0-flash-thinking": 32768,
"gemini-2.0-flash-lite": 1048576,