Miscs for Interro31

This commit is contained in:
2026-06-06 09:27:48 +02:00
parent 9e8b9ac191
commit 80d06e4693
9 changed files with 35 additions and 31 deletions
+12 -1
View File
@@ -175,7 +175,18 @@ def call_gemini_with_retries(model_id, contents, config,
except Exception as e:
error_msg = str(e).lower()
is_quota_error = "429" in error_msg or "quota" in error_msg or "exhausted" in error_msg
is_minute_limit = "minute" in error_msg or "rpm" in error_msg or "tpm" in error_msg
if is_minute_limit:
import re
# Extract wait time if present, else use default delay
retry_match = re.search(r"retry in ([\d.]+)s", error_msg)
wait_time = float(retry_match.group(1)) + 1.0 if retry_match else delays[attempt]
tprint(f"\tGemini Pro minute limit hit. Waiting {wait_time:.1f}s...")
time.sleep(wait_time)
continue # Retry same model
# Immediately fallback to Flash without waiting if it's a Pro quota error
if is_quota_error and model_id == MODEL_ID_pro and fallback_model_id:
tprint(f"\tGemini Pro quota hit ({e}). \n\n\tFalling back to Flash permanently...")
@@ -552,7 +563,7 @@ if __name__ == "__main__":
for label in all_labels:
if label.startswith(args.batch_from):
args.batch_from = label
print("Batching from : ", args.batch_from)
input(f"About to batch from: {args.batch_from}. Press Enter to confirm...")
break
if args.batch_from not in all_labels:
sys.exit(f"Error: Label '{args.batch_from}' not found. Available labels: {all_labels}")