Implementation:AIScientists Dev WorldSeed search candidates
| Knowledge Sources | |
|---|---|
| Domains | Asset_Sourcing, CLI |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete CLI script that searches one supported museum/archive source for an entity query, downloads candidates, and appends results to a bundle manifest with fit classification, provided by the WorldSeed library.
Description
The search_candidates script supports ten sources (Met, AIC, Cleveland, V&A, Wellcome, YCBA, Walters, Wikimedia, NASA, Openverse) via per-source search functions. The `Fetcher` class handles rate-limited HTTP with per-host minimum intervals, SSL context, and transient-error retries. `classify_fit` scores each candidate as exact/adjacent/vibe/miss based on entity label terms and role-specific hints. `append_candidates` deduplicates by entity+source+title key, optionally downloads images, and records a search-run summary. A file lock (`fcntl.flock`) ensures safe concurrent appends, and `_merge_manifest_updates` deduplicates candidates and runs across concurrent writers.
Usage
Run this script from the command line with a manifest, entity ID, source, and query. It appends candidates to the manifest JSON and prints a summary to stdout. Multiple invocations accumulate results in the same manifest.
Code Reference
Source Location
- Repository: WorldSeed
- File: skills/asset-sourcing/scripts/search_candidates.py
Signature
class Fetcher:
def __init__(self) -> None: ...
def json(self, url: str, *, extra_headers: dict[str, str] | None = None) -> tuple[dict[str, Any], int]: ...
def bytes(self, url: str) -> tuple[bytes, dict[str, str], int]: ...
def classify_fit(entity: dict[str, Any], candidate: SearchCandidate, query_type: str) -> tuple[str, str]: ...
def append_candidates(
manifest: dict[str, Any], *, bundle_dir: Path, entity: dict[str, Any],
source: str, query: str, query_type: str, query_round: int,
source_tier: str, limit: int, download: bool,
) -> dict[str, Any]:
"""Search source, classify fit, optionally download, append to manifest."""
def main() -> int:
"""CLI entry with argparse."""
Import
from skills.asset_sourcing.scripts.search_candidates import append_candidates, classify_fit, Fetcher, SearchCandidate
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| manifest | dict[str, Any] | Yes | Bundle manifest JSON |
| entity | dict[str, Any] | Yes | Entity with id, label, role |
| source | str | Yes | One of: met, aic, cleveland, vam, wellcome, ycba, walters, wikimedia, nasa, openverse |
| query | str | Yes | Search query string |
| download | bool | No | Whether to download images (default False) |
Outputs
| Name | Type | Description |
|---|---|---|
| append_candidates returns | dict[str, Any] | Run summary: counts, latencies, errors |
| manifest side effect | None | Candidates + search_runs appended to manifest |
Usage Examples
# CLI: search the Met for "tea house interior"
python skills/asset-sourcing/scripts/search_candidates.py \
--manifest manifest.json \
--entity-id teahouse \
--source met \
--query "tea house interior" \
--download
# Programmatic usage
from pathlib import Path
from skills.asset_sourcing.scripts.search_candidates import append_candidates
manifest = json.loads(Path("manifest.json").read_text())
entity = {"id": "teahouse", "label": "Tea House", "role": "zone"}
summary = append_candidates(
manifest, bundle_dir=Path("."), entity=entity,
source="met", query="tea house interior",
query_type="related", query_round=1,
source_tier="default", limit=8, download=True,
)