1616
1717from google .adk .utils .model_name_utils import extract_model_name
1818from google .adk .utils .model_name_utils import is_gemini_1_model
19- from google .adk .utils .model_name_utils import is_gemini_2_model
19+ from google .adk .utils .model_name_utils import is_gemini_2_or_above
2020from google .adk .utils .model_name_utils import is_gemini_model
2121
2222
@@ -165,46 +165,51 @@ def test_is_gemini_1_model_edge_cases(self):
165165
166166
167167class TestIsGemini2Model :
168- """Test the is_gemini_2_model function."""
169-
170- def test_is_gemini_2_model_simple_names (self ):
171- """Test Gemini 2.x model detection with simple model names."""
172- assert is_gemini_2_model ('gemini-2.0-flash' ) is True
173- assert is_gemini_2_model ('gemini-2.5-pro' ) is True
174- assert is_gemini_2_model ('gemini-2.0-flash-001' ) is True
175- assert is_gemini_2_model ('gemini-2.9-experimental' ) is True
176- assert is_gemini_2_model ('gemini-1.5-flash' ) is False
177- assert is_gemini_2_model ('gemini-1.0-pro' ) is False
178- assert is_gemini_2_model ('gemini-3.0-pro' ) is False # Only 2.x versions
179- assert is_gemini_2_model ('claude-3-sonnet' ) is False
180-
181- def test_is_gemini_2_model_path_based_names (self ):
182- """Test Gemini 2.x model detection with path-based model names."""
168+ """Test the is_gemini_2_or_above function."""
169+
170+ def test_is_gemini_2_or_above_simple_names (self ):
171+ """Test Gemini 2.0+ model detection with simple model names."""
172+ assert is_gemini_2_or_above ('gemini-2.0-flash' ) is True
173+ assert is_gemini_2_or_above ('gemini-2.5-pro' ) is True
174+ assert is_gemini_2_or_above ('gemini-2.0-flash-001' ) is True
175+ assert is_gemini_2_or_above ('gemini-2.9-experimental' ) is True
176+ assert is_gemini_2_or_above ('gemini-2-pro' ) is True
177+ assert is_gemini_2_or_above ('gemini-2' ) is True
178+ assert is_gemini_2_or_above ('gemini-3.0-pro' ) is True
179+ assert is_gemini_2_or_above ('gemini-1.5-flash' ) is False
180+ assert is_gemini_2_or_above ('gemini-1.0-pro' ) is False
181+ assert is_gemini_2_or_above ('claude-3-sonnet' ) is False
182+
183+ def test_is_gemini_2_or_above_path_based_names (self ):
184+ """Test Gemini 2.0+ model detection with path-based model names."""
183185 gemini_2_path = 'projects/265104255505/locations/us-central1/publishers/google/models/gemini-2.0-flash-001'
184- assert is_gemini_2_model (gemini_2_path ) is True
186+ assert is_gemini_2_or_above (gemini_2_path ) is True
185187
186188 gemini_2_path_2 = 'projects/12345/locations/us-east1/publishers/google/models/gemini-2.5-pro-preview'
187- assert is_gemini_2_model (gemini_2_path_2 ) is True
189+ assert is_gemini_2_or_above (gemini_2_path_2 ) is True
188190
189191 gemini_1_path = 'projects/265104255505/locations/us-central1/publishers/google/models/gemini-1.5-flash-001'
190- assert is_gemini_2_model (gemini_1_path ) is False
192+ assert is_gemini_2_or_above (gemini_1_path ) is False
191193
192- def test_is_gemini_2_model_edge_cases (self ):
193- """Test edge cases for Gemini 2.x model detection."""
194+ gemini_3_path = 'projects/12345/locations/us-east1/publishers/google/models/gemini-3.0-pro'
195+ assert is_gemini_2_or_above (gemini_3_path ) is True
196+
197+ def test_is_gemini_2_or_above_edge_cases (self ):
198+ """Test edge cases for Gemini 2.0+ model detection."""
194199 # Test with None
195- assert is_gemini_2_model (None ) is False
200+ assert is_gemini_2_or_above (None ) is False
196201
197202 # Test with empty string
198- assert is_gemini_2_model ('' ) is False
203+ assert is_gemini_2_or_above ('' ) is False
199204
200205 # Test with model names containing gemini-2 but not starting with it
201- assert is_gemini_2_model ('my-gemini-2.5-model' ) is False
202- assert is_gemini_2_model ('custom-gemini-2.0-flash' ) is False
206+ assert is_gemini_2_or_above ('my-gemini-2.5-model' ) is False
207+ assert is_gemini_2_or_above ('custom-gemini-2.0-flash' ) is False
203208
204209 # Test with invalid versions
205- assert is_gemini_2_model ('gemini-2' ) is False # Missing dot
206- assert is_gemini_2_model ('gemini-2-pro ' ) is False # Missing dot
207- assert is_gemini_2_model ('gemini-2. ' ) is False # Missing version number
210+ assert is_gemini_2_or_above ('gemini-2. ' ) is False # Missing version number
211+ assert is_gemini_2_or_above ('gemini-0.9-test ' ) is False
212+ assert is_gemini_2_or_above ('gemini-one ' ) is False
208213
209214
210215class TestModelNameUtilsIntegration :
@@ -216,32 +221,34 @@ def test_model_classification_consistency(self):
216221 'gemini-1.5-flash' ,
217222 'gemini-2.0-flash' ,
218223 'gemini-2.5-pro' ,
224+ 'gemini-3.0-pro' ,
219225 'projects/123/locations/us-central1/publishers/google/models/gemini-1.5-pro' ,
220226 'projects/123/locations/us-central1/publishers/google/models/gemini-2.0-flash' ,
227+ 'projects/123/locations/us-central1/publishers/google/models/gemini-3.0-pro' ,
221228 'claude-3-sonnet' ,
222229 'gpt-4' ,
223230 ]
224231
225232 for model in test_models :
226- # A model can only be either Gemini 1.x or Gemini 2.x , not both
233+ # A model can only be either Gemini 1.x or Gemini 2.0+ , not both
227234 if is_gemini_1_model (model ):
228- assert not is_gemini_2_model (
235+ assert not is_gemini_2_or_above (
229236 model
230- ), f'Model { model } classified as both Gemini 1.x and 2.x '
237+ ), f'Model { model } classified as both Gemini 1.x and 2.0+ '
231238 assert is_gemini_model (
232239 model
233240 ), f'Model { model } is Gemini 1.x but not classified as Gemini'
234241
235- if is_gemini_2_model (model ):
242+ if is_gemini_2_or_above (model ):
236243 assert not is_gemini_1_model (
237244 model
238- ), f'Model { model } classified as both Gemini 1.x and 2.x '
245+ ), f'Model { model } classified as both Gemini 1.x and 2.0+ '
239246 assert is_gemini_model (
240247 model
241- ), f'Model { model } is Gemini 2.x but not classified as Gemini'
248+ ), f'Model { model } is Gemini 2.0+ but not classified as Gemini'
242249
243- # If it's neither Gemini 1.x nor 2.x , it should not be classified as Gemini
244- if not is_gemini_1_model (model ) and not is_gemini_2_model (model ):
250+ # If it's neither Gemini 1.x nor 2.0+ , it should not be classified as Gemini
251+ if not is_gemini_1_model (model ) and not is_gemini_2_or_above (model ):
245252 if model and 'gemini-' not in extract_model_name (model ):
246253 assert not is_gemini_model (
247254 model
@@ -262,6 +269,10 @@ def test_path_vs_simple_model_consistency(self):
262269 'gemini-2.5-pro' ,
263270 'projects/123/locations/us-central1/publishers/google/models/gemini-2.5-pro' ,
264271 ),
272+ (
273+ 'gemini-3.0-pro' ,
274+ 'projects/123/locations/us-central1/publishers/google/models/gemini-3.0-pro' ,
275+ ),
265276 (
266277 'claude-3-sonnet' ,
267278 'projects/123/locations/us-central1/publishers/google/models/claude-3-sonnet' ,
@@ -278,7 +289,9 @@ def test_path_vs_simple_model_consistency(self):
278289 f'Inconsistent Gemini 1.x classification for { simple_model } vs'
279290 f' { path_model } '
280291 )
281- assert is_gemini_2_model (simple_model ) == is_gemini_2_model (path_model ), (
282- f'Inconsistent Gemini 2.x classification for { simple_model } vs'
292+ assert is_gemini_2_or_above (simple_model ) == is_gemini_2_or_above (
293+ path_model
294+ ), (
295+ f'Inconsistent Gemini 2.0+ classification for { simple_model } vs'
283296 f' { path_model } '
284297 )
0 commit comments