mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
Fix vision attachment timeout and stale cache
Increase local vision model timeout and avoid caching transient VL failure placeholders.\n\nCloses #202.
This commit is contained in:
committed by
GitHub
parent
71d74290f0
commit
4a04068818
+5
-2
@@ -223,17 +223,20 @@ class ChatHandler:
|
|||||||
if os.path.exists(_vcache):
|
if os.path.exists(_vcache):
|
||||||
try:
|
try:
|
||||||
with open(_vcache) as _vf:
|
with open(_vcache) as _vf:
|
||||||
vl_desc = _vf.read()
|
cached_desc = _vf.read().strip()
|
||||||
|
if cached_desc and not cached_desc.startswith("["):
|
||||||
|
vl_desc = cached_desc
|
||||||
except Exception:
|
except Exception:
|
||||||
vl_desc = None
|
vl_desc = None
|
||||||
if not vl_desc:
|
if not vl_desc:
|
||||||
vl_result = analyze_image_with_vl_result(file_info["path"])
|
vl_result = analyze_image_with_vl_result(file_info["path"])
|
||||||
vl_desc = vl_result.get("text", "")
|
vl_desc = vl_result.get("text", "")
|
||||||
vl_model = vl_result.get("model", "")
|
vl_model = vl_result.get("model", "")
|
||||||
|
if vl_desc and not vl_desc.startswith("["):
|
||||||
try:
|
try:
|
||||||
os.makedirs(os.path.join(UPLOAD_DIR, ".vision"), exist_ok=True)
|
os.makedirs(os.path.join(UPLOAD_DIR, ".vision"), exist_ok=True)
|
||||||
with open(_vcache, "w") as _vf:
|
with open(_vcache, "w") as _vf:
|
||||||
_vf.write(vl_desc or "")
|
_vf.write(vl_desc)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
enhanced_message = f"{enhanced_message}\n\n[Image: {file_info['name']}]\n{vl_desc}"
|
enhanced_message = f"{enhanced_message}\n\n[Image: {file_info['name']}]\n{vl_desc}"
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ def analyze_image_with_vl_result(image_path: str) -> dict:
|
|||||||
last_err = None
|
last_err = None
|
||||||
for i, (_url, _model, _headers) in enumerate([c for c in _vl_candidates if c and c[0] and c[1]]):
|
for i, (_url, _model, _headers) in enumerate([c for c in _vl_candidates if c and c[0] and c[1]]):
|
||||||
try:
|
try:
|
||||||
description = llm_call(_url, _model, vl_messages, headers=_headers, timeout=30)
|
description = llm_call(_url, _model, vl_messages, headers=_headers, timeout=120)
|
||||||
logger.info("VL analysis complete with model %s", _model)
|
logger.info("VL analysis complete with model %s", _model)
|
||||||
return {"text": description, "model": _model}
|
return {"text": description, "model": _model}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user