openpencil/apps/web/server
Fini 40ce4d46eb fix(ai): image-search retries with 2-keyword query when 3-keyword returns 0
Two of five food-app placeholder images shipped unfilled because
Openverse returned `[]` for the model's 3-keyword queries:
  - "burger combo fries"   → 0 results
  - "sakura sushi platter" → 0 results

The same queries truncated to the first two words have plenty:
  - "burger fries"  → 240 results
  - "sushi platter" → 240 results

Openverse uses strict AND-search across all keywords, so a 3-word
query that includes any low-frequency or non-matching token
zero-results even when the photos exist. The skill prompt already
nudges models toward "2-3 English keywords" but they often pick three
when the brief mentions a third descriptor (e.g. "Tasty BURGER COMBO
fries" → "burger combo fries").

Endpoint now cascades:
  1. Openverse with full query.
  2. If `[]` and query has > 2 words: re-query with first 2 words.
  3. If still nothing usable: fall through to Wikimedia (existing path)
     with the same 2-word retry safety net.

Returning the original empty result was wrong: the placeholder stays
unfilled even though a satisfactory photo for "burger fries" was one
keyword-trim away. The trade-off is losing a small amount of relevance
on the dropped 3rd keyword — but that's better than no photo at all,
and the model still drives the first two keywords which carry the
core subject.
2026-05-05 12:22:44 +08:00
..
__tests__ Merge origin/v0.8.0 into feat/rust-ification 2026-05-03 21:00:00 +08:00
api fix(ai): image-search retries with 2-keyword query when 3-keyword returns 0 2026-05-05 12:22:44 +08:00
opencode V0.7.3 (#111) 2026-04-15 22:19:12 +08:00
plugins V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
utils fix(ai): proxy dispatcher uses ESM import, actually installs in dev path 2026-05-05 12:22:40 +08:00