diff --git a/rag_refresh.py b/rag_refresh.py index c937c4f..759a282 100644 --- a/rag_refresh.py +++ b/rag_refresh.py @@ -91,7 +91,13 @@ for name in DOCS: print(f"rag_refresh: upload failed for {name}: {e}", file=sys.stderr) continue fid = resp.get("id") - code, _ = api(f"/api/v1/knowledge/{KB_ID}/file/add", {"file_id": fid}) + # attach can 400 transiently right after upload (file still processing) — retry + code = None + for attempt in range(3): + code, _ = api(f"/api/v1/knowledge/{KB_ID}/file/add", {"file_id": fid}) + if code == 200: + break + time.sleep(5 * (attempt + 1)) if code != 200: print(f"rag_refresh: attach failed for {name}: {code}", file=sys.stderr) continue