Mirrowel commited on
Commit
f7eb788
Β·
1 Parent(s): 9756075

fix(auth): πŸ› remove deprecated gemini models fallback

Browse files

Remove deprecated preview fallbacks so fallback chains return only base models. Add an explicit `has_fallbacks` check to detect whether real fallback models exist and skip fallback logic when none are available. Improve debug/info logs to clearly indicate when fallbacks are present or when a single model is being attempted, preventing unnecessary fallback attempts and clarifying runtime behavior.

src/rotator_library/providers/gemini_cli_provider.py CHANGED
@@ -356,14 +356,18 @@ class GeminiCliProvider(GeminiAuthBase, ProviderInterface):
356
  """
357
  Returns a list of model names to try in order for rate limit fallback.
358
  First model in list is the original model, subsequent models are fallback options.
 
 
 
359
  """
360
  # Remove provider prefix if present
361
  model_name = model.split('/')[-1].replace(':thinking', '')
362
 
363
  # Define fallback chains for models with preview versions
 
364
  fallback_chains = {
365
- "gemini-2.5-pro": ["gemini-2.5-pro", "gemini-2.5-pro-preview-06-05"],
366
- "gemini-2.5-flash": ["gemini-2.5-flash", "gemini-2.5-flash-preview-05-20"],
367
  # Add more fallback chains as needed
368
  }
369
 
@@ -903,15 +907,23 @@ class GeminiCliProvider(GeminiAuthBase, ProviderInterface):
903
 
904
  return logging_stream_wrapper()
905
 
906
- # Try each model in fallback order on rate limit
 
 
 
907
  lib_logger.debug(f"Fallback models available: {fallback_models}")
 
 
 
908
  last_error = None
909
  for idx, attempt_model in enumerate(fallback_models):
910
  is_fallback = idx > 0
911
  if is_fallback:
912
  lib_logger.info(f"Gemini CLI rate limited, retrying with fallback model: {attempt_model}")
913
- elif len(fallback_models) > 1:
914
  lib_logger.debug(f"Attempting primary model: {attempt_model} (with {len(fallback_models)-1} fallback(s) available)")
 
 
915
 
916
  try:
917
  response_gen = await do_call(attempt_model, is_fallback)
 
356
  """
357
  Returns a list of model names to try in order for rate limit fallback.
358
  First model in list is the original model, subsequent models are fallback options.
359
+
360
+ Since all fallbacks have been deprecated, this now only returns the base model.
361
+ The fallback logic will check if there are actual fallbacks available.
362
  """
363
  # Remove provider prefix if present
364
  model_name = model.split('/')[-1].replace(':thinking', '')
365
 
366
  # Define fallback chains for models with preview versions
367
+ # All fallbacks have been deprecated, so only base models are returned
368
  fallback_chains = {
369
+ "gemini-2.5-pro": ["gemini-2.5-pro"],
370
+ "gemini-2.5-flash": ["gemini-2.5-flash"],
371
  # Add more fallback chains as needed
372
  }
373
 
 
907
 
908
  return logging_stream_wrapper()
909
 
910
+ # Check if there are actual fallback models available
911
+ # If fallback_models is empty or contains only the base model (no actual fallbacks), skip fallback logic
912
+ has_fallbacks = len(fallback_models) > 1 and any(model != fallback_models[0] for model in fallback_models[1:])
913
+
914
  lib_logger.debug(f"Fallback models available: {fallback_models}")
915
+ if not has_fallbacks:
916
+ lib_logger.debug("No actual fallback models available, proceeding with single model attempt")
917
+
918
  last_error = None
919
  for idx, attempt_model in enumerate(fallback_models):
920
  is_fallback = idx > 0
921
  if is_fallback:
922
  lib_logger.info(f"Gemini CLI rate limited, retrying with fallback model: {attempt_model}")
923
+ elif has_fallbacks:
924
  lib_logger.debug(f"Attempting primary model: {attempt_model} (with {len(fallback_models)-1} fallback(s) available)")
925
+ else:
926
+ lib_logger.debug(f"Attempting model: {attempt_model} (no fallbacks available)")
927
 
928
  try:
929
  response_gen = await do_call(attempt_model, is_fallback)