Skip to content

vec-cache@1.2.0

Choose a tag to compare

@github-actions github-actions released this 27 Sep 10:11
· 10 commits to master since this release
60d4b29

Minor Changes

  • 376af3e: Add findMissing(texts, options), which returns the texts that still need embedding without reading any vectors.

    Answering "which of these documents do I still need to embed?" used to mean calling getMany, which copies and decodes a full vector for every hit only for the caller to discard it. findMissing runs the same lookup over each row's key and dimensions only. It returns exactly the list getOrCreate would pass to embed for the same batch: each missing text once, in first-occurrence order, with expired entries and wrong-width hits counted as missing. It takes the same options as getMany.

Patch Changes

  • 0965774: getOrCreate now returns every vector, hit or miss, as a typed array in the instance's vectorEncoding.

    A miss used to come back as whatever embed returned, usually a full-precision number[], while a hit came back as a decoded Float32Array. One result could mix both, JSON.stringify rendered one as an array and the other as an object, and a text's first call returned different numbers from its later hits. A miss is now converted to the value the cache stored: Float32Array by default, Float64Array under vectorEncoding: 'float64'. Set vectorEncoding: 'float64' to keep the full precision embed returned. getMany also converts a row written under another vectorEncoding to the instance's.

  • 719a52f: Rewriting a cache entry now resets its creation time.

    Re-embedding a TTL-expired entry, or calling setMany over an existing key, used to keep the old created_at_ms. prune({ olderThanMs }) could then delete a row that had just been paid for, forcing another embed on the next request, and stats().newestEntryMs did not reflect the rewrite. An entry's age now counts from its latest write, as its expires_at_ms already did.