fix: adjust batch size to 50 and enforce strict Lite-only policy

- Reduced BATCH_SIZE_FAST to 50 to prevent AI request timeouts.
- Hardened call_gemini_with_retry to strictly use Flash/Lite models when prefer_flash=True.
- Ensured newest model versions are prioritized within the Flash tier.
This commit is contained in:
Nubenetes Bot
2026-05-21 11:25:50 +02:00
parent 15cb72fbba
commit d05afb2970
2 changed files with 7 additions and 3 deletions

View File

@@ -293,9 +293,13 @@ async def call_gemini_with_retry(prompt: str, response_format: str = "json", max
consecutive_429s = 0
base_wait_time = 2.0
# 1. Smart Re-ordering
# 1. Smart Filtering and Re-ordering (Strict Lite-Only Policy for Tier 1)
if prefer_flash:
models = sorted(models_pool, key=lambda m: 0 if "flash" in m or "lite" in m else 1)
# Strict filter: Only allow flash/lite models, maintaining version sorting from pool
models = [m for m in models_pool if "flash" in m or "lite" in m]
if not models:
# Emergency fallback: if no flash/lite discovered, use hardcoded safe defaults
models = ["gemini-1.5-flash", "gemini-1.5-flash-latest"]
else:
models = models_pool

View File

@@ -319,7 +319,7 @@ class V2VisionEngine:
analyst_results = []
# 1.1 Fast-Track: Large Batches, NO GROUNDING (Fast)
BATCH_SIZE_FAST = 100 # Increased from 40 for optimal RPM/TPM balance
BATCH_SIZE_FAST = 50 # Balanced "Sweet Spot" for RPM/TPM and timeout safety (2026)
total_fast = len(fast_track)
for i in range(0, total_fast, BATCH_SIZE_FAST):
batch = fast_track[i:i+BATCH_SIZE_FAST]