Skip to content

Commit 9aae68a

Browse files
Jing-yilinclaude
andcommitted
fix: switch to stable Gemini model and reduce rate limit pressure
Changed from gemini-2.0-flash-exp to gemini-1.5-flash-002: - Experimental models have strict rate limits (quota exhausted errors) - Stable model has higher quotas and better availability - Reduced batch size from 10 to 5 campaigns - Increased batch delay from 500ms to 2s This prevents "Quota exceeded for generate_content_requests_per_minute" errors during backfill operations. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 1669976 commit 9aae68a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

backend/internal/service/translator.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ func (t *TranslatorService) TranslateCampaigns(campaigns []model.Campaign) error
5959
return nil
6060
}
6161

62-
// Use Gemini 2.0 Flash via Vertex AI (uses startup credits)
63-
model := t.client.GenerativeModel("gemini-2.0-flash-exp")
62+
// Use Gemini 1.5 Flash (stable model with higher quotas than experimental)
63+
model := t.client.GenerativeModel("gemini-1.5-flash-002")
6464
model.SetTemperature(0.3) // Lower temperature for more consistent translations
6565

66-
// Batch translate in groups of 10 to avoid token limits
67-
const batchSize = 10
66+
// Batch translate in groups of 5 to stay within rate limits
67+
const batchSize = 5
6868
for i := 0; i < len(campaigns); i += batchSize {
6969
end := i + batchSize
7070
if end > len(campaigns) {
@@ -78,9 +78,9 @@ func (t *TranslatorService) TranslateCampaigns(campaigns []model.Campaign) error
7878
continue
7979
}
8080

81-
// Rate limiting: small delay between batches
81+
// Rate limiting: 2-second delay between batches to avoid quota exhaustion
8282
if end < len(campaigns) {
83-
time.Sleep(500 * time.Millisecond)
83+
time.Sleep(2 * time.Second)
8484
}
8585
}
8686

0 commit comments

Comments
 (0)