Use different seeds for retries
This commit is contained in:
1 parent
c58bbc3672
commit
b6c2a634ca
7 files changed
+91
-10
No files matched your search
@@ -15,12 +15,13 @@ from collections.abc import Sequence
|
||||
from pathlib import Path
|
||||
|
||||
from google import genai
|
||||
from google.genai import types
|
||||
|
||||
from copienator import configuration as config
|
||||
from copienator.commands import grouping
|
||||
from copienator.answer_origins import save_origins
|
||||
from copienator import prompting
|
||||
from copienator.gemini_config import thinking_config
|
||||
from copienator.gemini_config import fresh_seed, thinking_config
|
||||
from copienator import configuration as settings
|
||||
from copienator.feedback_boxes import valid_feedback_box
|
||||
from copienator.latex_json import repair_latex_json
|
||||
@@ -274,10 +275,19 @@ def call_gemini_with_retries(model_id, contents, config,
|
||||
"""Handles requests to Gemini with a 1min and 5min retry mechanism, and quota fallback."""
|
||||
global pro_quota_exhausted
|
||||
delays = [60, 300]
|
||||
request_seed = None
|
||||
# Own the retries here so the SDK cannot silently resend a fixed seed.
|
||||
http_options = config.http_options or types.HttpOptions()
|
||||
config = config.model_copy(update={"http_options": http_options.model_copy(
|
||||
update={"retry_options": types.HttpRetryOptions(attempts=1)}
|
||||
)})
|
||||
|
||||
for attempt in range(3):
|
||||
if stop_requested.is_set():
|
||||
raise CorrectionStopRequested
|
||||
request_seed = fresh_seed(request_seed)
|
||||
config = config.model_copy(update={"seed": request_seed})
|
||||
tprint(f"\tGemini attempt {attempt + 1}/3: seed={request_seed}")
|
||||
# Switch to fallback immediately if quota was exhausted by another thread
|
||||
if model_id == MODEL_ID_pro and pro_quota_exhausted and fallback_model_id:
|
||||
model_id = fallback_model_id
|
||||
|
||||
Reference in new issue
Block a user