chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase
This commit is contained in:
parent
970e08c466
commit
1f7e365a4e
237 changed files with 1951 additions and 49413 deletions
|
|
@ -14,9 +14,11 @@ const patterns = new Map(EMBEDDED_PATTERNS.map(p => [p.id, p]))
|
|||
const patternEmbeddings = getPatternEmbeddings()
|
||||
|
||||
/**
|
||||
* Cosine similarity between two vectors
|
||||
* Cosine similarity between two vectors.
|
||||
* Accepts any number-indexed sequence so pre-computed Float32Array pattern
|
||||
* embeddings can be compared against number[] query vectors without copying.
|
||||
*/
|
||||
function cosineSimilarity(a: Vector, b: Vector): number {
|
||||
function cosineSimilarity(a: ArrayLike<number>, b: ArrayLike<number>): number {
|
||||
if (!a || !b || a.length !== b.length) return 0
|
||||
|
||||
let dotProduct = 0
|
||||
|
|
@ -99,7 +101,7 @@ export function findBestPatterns(
|
|||
if (!patternEmbedding) continue
|
||||
|
||||
// Pass Float32Array directly, no need for Array.from()!
|
||||
const similarity = cosineSimilarity(queryEmbedding, patternEmbedding as any)
|
||||
const similarity = cosineSimilarity(queryEmbedding, patternEmbedding)
|
||||
if (similarity > 0.5) { // Threshold for relevance
|
||||
matches.push({ pattern, similarity })
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue