agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
19 lines • 805 B
TypeScript
/**
* cosineSimilarity — the similarity metric used by `store.search()`.
*
* cos(a, b) = dot(a, b) / (||a|| * ||b||)
*
* Range: [-1, 1]. Equal-direction vectors → 1. Orthogonal → 0.
* Opposite → -1.
*
* Zero-magnitude handling: if either vector is all-zero (or the empty
* vector), returns 0 — never NaN. NaN in a similarity score would
* poison downstream picker comparisons (NaN < x is false for all x)
* and silently demote the entry. Explicit 0 is safer.
*
* Length mismatch THROWS: comparing vectors of different dimensions
* is almost always a bug (different embedders mixed in the same store).
* Fail loud rather than silently truncate.
*/
export declare function cosineSimilarity(a: readonly number[], b: readonly number[]): number;
//# sourceMappingURL=cosine.d.ts.map