fix: rejeter bavardage VLM dans _vlm_identify_element

Le VLM 8B répond souvent avec "several UI elements", "I can see",
etc. au lieu d'un label court. Ces réponses remplissaient by_text
avec du non-sens, empêchant le som_anchor_match de se déclencher
pour les icônes sans texte (disquette, fermer, etc.).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dom
2026-03-31 15:44:56 +02:00
parent 68d5bb7dd1
commit 7dec3ab63a

View File

@@ -502,14 +502,24 @@ def _vlm_identify_element(anchor_b64: str, window_title: str = "") -> str:
if raw.lower().startswith(prefix.lower()):
raw = raw[len(prefix):]
break
# Rejeter les réponses qui sont du bavardage, pas un label
reject_patterns = (
"several", "multiple", "various", "image",
"I can", "there are", "there is", "elements",
"the following", "here are",
)
if any(p in raw.lower()[:30] for p in reject_patterns):
logger.debug("VLM identify : réponse bavarde rejetée (raw='%s')", raw[:60])
return ""
# Prendre les 5 premiers mots utiles
words = raw.split()[:5]
label = " ".join(words).strip('",.\' ').rstrip(".")
if label and 2 <= len(label) <= 60:
if label and 2 <= len(label) <= 40:
logger.info("VLM identify element : '%s'", label)
return label
else:
logger.debug("VLM identify : label trop court ou vide après nettoyage (raw='%s')", raw[:80])
logger.debug("VLM identify : label trop court/long après nettoyage (raw='%s')", raw[:80])
except Exception as e:
logger.debug("VLM identify element échoué : %s", e)