Miscs fixes

This commit is contained in:
2026-03-31 10:58:51 +02:00
parent f16c0273bd
commit bc59b2aeea
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -184,7 +184,7 @@ def tprint(*args, **kwargs):
thread_logs[tid] = []
thread_logs[tid].append(msg)
Optional: Keep printing to console but prefix with thread name
# Optional: Keep printing to console but prefix with thread name
print(f"[{tid}] {msg}", **kwargs)
def flush_thread_log(tid=None):
@@ -192,7 +192,7 @@ def flush_thread_log(tid=None):
tid = tid or threading.current_thread().name
with log_lock:
if thread_logs.get(tid):
with open("correction_log", "a", encoding="utf-8") as f:
with open(Path(INPUT_DIR) / "correction_log", "a", encoding="utf-8") as f:
f.write(f"--- Task Log [{tid}] ---\n")
f.write("\n".join(thread_logs[tid]) + "\n\n")
thread_logs[tid].clear()
@@ -313,7 +313,7 @@ def call_gemini_with_retries(model_id, contents, config,
# 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}). Falling back to Flash permanently...")
tprint(f"\tGemini Pro quota hit ({e}). \n\n\tFalling back to Flash permanently...")
model_id = fallback_model_id
pro_quota_exhausted = True
continue # Retry immediately with Flash
@@ -591,7 +591,7 @@ def process_single_task(task_tuple):
yming, ymaxg, width_r = d_data[pid]
pdf_path = Path(INPUT_DIR) / f"Copie{pid}" / f"{label}.pdf"
if !can_spawn_tasks and res["error"] == "additional-answer":
if (not can_spawn_tasks) and res["error"] == "additional-answer":
tprint("\tSwallowing an additional-answer from a subsequent task.")
res["error"]= ""
if res["error"] != "":
@@ -602,7 +602,7 @@ def process_single_task(task_tuple):
needs_correction = []
for (i,f) in enumerate(res["feedback"]):
b = f["box_2d"]
b = f.get("box_2d")
if b:
ymin, xmin, ymax, xmax = b
ymin = ymin * total_height // 1000