Repository navigation
fix(provider-polyhaven): rank by match quality and popularity; cache the asset list - #42
Merged
Merged
Conversation
… document listTtlMs bounds
…ned cache/abort behaviour, deep raw copy, Unicode tokens
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Poly Haven results were effectively alphabetical, and every search downloaded the whole asset list.
Why
The list endpoint has no search, so the provider filtered client-side. It counted how many query words occurred as a substring anywhere in an asset and kept the API's alphabetical order on ties. It then capped results at
maxAssetsbefore core reranked them.Take "sunset HDRI", checked live on 997 HDRIs.
hdrimatches no asset.sunsetsubstring-matches 225 assets through thesunrise-sunsetcategory. All 225 tie, so the top 12 came back asaarfontein_dawn_2,aarfontein_dusk,aarfontein_panand so on.Separately, every search re-downloaded the list: about 1 MB for HDRIs and 0.86 MB for textures. Both sources are keyless and on by default in hosts.
Change
Ranking. Each query word scores its best match:
Assets are sorted by total score, then
download_count, then list order. Ranking happens before the page window. An empty query lists the most-downloaded first.Unicode tokens. Words in any script are kept whole (
crème,日落,सूर्यास्त). A non-Latin or punctuation-only query that matches nothing now returns[]. Before, it fell into the "no words" path.Asset list cache. Each provider instance downloads the list once and reuses it for an hour. The new
listTtlMsoption controls this, and0turns the cache off.rawis astructuredCloneof the cached asset, so a consumer mutating it cannot change later results.Live, before → after
A second search on the same instance makes no list request.
Testing
pnpm typecheck,pnpm lint,pnpm build,pnpm test:run(686 passed, 25 skipped) andpnpm smoke:artifact.REFKIT_LIVE=1conformance passes for polyhaven, polyhaven-hdri and ambientcg.The changeset is a patch for
@refkit/provider-polyhaven. It is the first release under trusted publishing that touches only one package.