8000 Show Seed Search's images on Combined Search with images=true by daoudclarke · Pull Request #631 · mwmbl/mwmbl · GitHub
[go: up one dir, main page]

Skip to content

Show Seed Search's images on Combined Search with images=true - #631

Merged
daoudclarke merged 4 commits into
mainfrom
seed-images-prod-api
Nov 11, 2026
Merged

daoudclarke merged 4 commits into
mainfrom
seed-images-prod-api

Conversation

@daoudclarke
@daoudclarke daoudclarke commented Nov 11, 2026 •
Copy link
Copy Markdown
Contributor

From Claude:

Stack: builds on #628 (seed-images-prod-pipeline), which builds on #622 -> #620 -> #624 -> #623 -> main.

What changed

PR 4 of the #610 plan wires Seed Search's image flow (mwmbl/imagesearch/seed_images.py, #628) into Combined Search.

  • images=true on GET /api/v2/combined-search/, for JWT and API keys alike, at no extra cost. Phase 1 (seed_images.start) starts before Staan is fetched. Phase 2 (seed_images.finish) is awaited alongside web ranking, which now runs as a task, together with the Staan index write.
  • New response fields:
    • image_outcome: shown | query_refused | not_needed | none_relevant | unavailable, null without images=true.
    • images_display_count: settings.IMAGES_DISPLAY_COUNT, 4.
    • images: the ImageResult fields ported from the eval branch's imagesearch/api.py, plus relevance, best first.
  • Strip images are removed from the web results. Matching is on a key built from the Commons File: URL, so percent-encoding, spaces and the mobile host don't defeat it.
  • Kill switch: IMAGE_SEARCH_ENABLED (env), on by default. When it is off, images=true answers unavailable and never calls Commons or the judge. It was off by default until the safety benchmark and injection probes had been re-run with captions; Re-measure image safety, gate and minimum with Commons captions #630 did that and the thresholds held, so it now defaults to on. That changes nothing for requests that don't send images=true, and an instance without JEV_API_KEY still answers unavailable without calling anything. Set IMAGE_SEARCH_ENABLED=false to stop image search without a deploy.
  • Logging: one INFO line per images=true request with the outcome, the image count, the total image latency and the time beyond web ranking. It never includes the query, titles or SHA-1s. The httpx logger is pinned to WARNING, because its INFO lines contain the Commons query URL.
  • API description:
    • what images=true does;
    • that the server sends the query to Wikimedia Commons, and the query, the top web results and the image text to a third-party LLM service (also for not_needed outcomes);
    • that the safety check covers nudity and sexual content judged from text only, with no pixel check;
    • the contract to show images_display_count images and put the rest behind "More";
    • that clients must escape titles and attribution;
    • that thumbnails must load with referrerpolicy="no-referrer" and come from Wikimedia, which sees the viewer's IP;
    • that license_url may be empty and should be linked with rel="noopener noreferrer nofollow";
    • fail-closed behaviour.
  • Question wording, in its own commit: the NSFW and relevance questions in mwmbl/imagesearch/prompt.py now say "file name, caption, description and categories", because captions are shown to the judge. This follows the caption eval, Re-measure image safety, gate and minimum with Commons captions #630:

Why

This is the API half of showing Commons images with Seed Search results (#610), so the front end can build the strip. It stays switched off until the safety re-run.

Verification

  • make check passes. make test passes (1882 passed after the review fixes; the image tests were re-run after the wording commit).
  • The new endpoint tests stub seed_images.start/finish. They cover:
    • no image search without the flag;
    • the field shapes and ordering;
    • that finish is handed web ranking while it is still running;
    • strip de-duplication, and no de-duplication when no images are shown;
    • the kill switch (Commons is never called);
    • API-key access;
    • that the log line has the outcome but not the query, titles or SHA-1s, captured at the root logger.
  • The OpenAPI test checks the new parameter and the image contract in the description.
  • Nothing was measured live.
  • A subagent review covered code, security, trust and safety, and the holistic questions. Fixed from it:
    • the description now discloses the third-party LLM and gives the licence-link and IP guidance;
    • the image log no longer relies on callback order to time web ranking (a fragile IndexError path);
    • the strip host set derives from the Commons client's, so a None key can't drop web results;
    • the privacy log test now captures every logger.
  • Left as follow-ups:
    • the key doesn't normalise first-letter case, the Image: alias or index.php?title= URLs (worst case, an image appears twice);
    • the httpx pin is an import-time setLevel rather than a LOGGING entry (the project has no LOGGING dict);
    • Sentry's httpx integration may record outgoing URLs as breadcrumbs, as it already does for Staan.

Part of #610

🤖 Generated with Claude Code

@codecov
codecov Bot commented Nov 11, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

daoudclarke and others added 3 commits November 11, 2026 11:00
Adds an images query parameter (JWT and API keys alike) and the image_outcome,
images_display_count and images response fields. The first phase of image
search starts before Staan, the second runs alongside web ranking, and images
shown in the strip are left out of the web results. IMAGE_SEARCH_ENABLED is
the kill switch, off by default until the safety benchmark is re-run with
captions. Outcome and latency are logged without the query or the images, and
the httpx logger, whose INFO lines carry the Commons query URL, is pinned to
WARNING. The API description tells front ends what the safety check covers,
that queries go to Wikimedia Commons, and how to render images safely.

Part of #610.

No functional changes to the crawler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… at the root

From review: the API description now says the query goes to a third-party LLM
service as well as to Commons, and how to link uploader-set licence URLs; the
image log no longer depends on callback order to time web ranking; the strip's
host set derives from the Commons client's; the privacy test captures every
logger.

No functional changes to the crawler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Commons captions are now part of each image's text (#628), so the questions
say so. The caption eval (#630) measured the NSFW rewording on the safety
benchmark: an identical table, and the 1.0 threshold holds. The relevance
rewording was not measured. The NSFW question's fingerprint changes, so cached
verdicts are asked again.

No functional changes to the crawler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The safety benchmark and injection probes held with captions (#630), so the
kill switch no longer needs to default to off. Only requests sending
images=true search images, and an instance without JEV_API_KEY still answers
unavailable without calling Commons or the judge.

No functional changes to the crawler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@daoudclarke
daoudclarke merged commit a0117aa into main Nov 11, 2026
7 checks passed
@daoudclarke
daoudclarke deleted the seed-images-prod-api branch November 11, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0