fix: AI review list UTC filter, vision timeout, and stuck loading state

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-05 13:59:17 +08:00
parent 4ac4c062e0
commit 3f1bf9905d
11 changed files with 199 additions and 122 deletions
+8 -3
View File
@@ -19,7 +19,12 @@ def _env_str(name: str, default: str = "") -> str:
return str(v).strip()
def _ai_timeout_seconds() -> int:
def _ai_timeout_seconds(*, image_count: int = 0) -> int:
if image_count > 0:
try:
return max(30, int(_env_str("AI_REVIEW_TIMEOUT_SECONDS", "300") or "300"))
except ValueError:
return 300
try:
return max(10, int(_env_str("AI_TIMEOUT_SECONDS", "120") or "120"))
except ValueError:
@@ -129,7 +134,7 @@ def _generate_openai(prompt: str, images: List[tuple], temperature: float) -> st
_openai_chat_url(),
headers=headers,
json=body,
timeout=_ai_timeout_seconds(),
timeout=_ai_timeout_seconds(image_count=len(images)),
)
r.raise_for_status()
data = r.json()
@@ -149,7 +154,7 @@ def _generate_ollama(prompt: str, images: List[tuple], temperature: float) -> st
}
if images:
payload["images"] = [b64 for b64, _mime in images]
r = requests.post(_ollama_api(), json=payload, timeout=_ai_timeout_seconds())
r = requests.post(_ollama_api(), json=payload, timeout=_ai_timeout_seconds(image_count=len(images)))
r.raise_for_status()
return (r.json().get("response") or "").strip() or "AI 生成失败"