refactor: eradicate deprecated tools (sticky_notes, pinned_files, context_workspaces, pr_checklist, preferences) and dead code
This commit is contained in:
1 parent
d80915635f
commit
79209da711
31 files changed
+1230
-3920
No files matched your search
@@ -280,12 +280,16 @@ pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32 {
|
||||
norm_b_sq += y * y;
|
||||
}
|
||||
|
||||
let norm_a = norm_a_sq.sqrt();
|
||||
let norm_b = norm_b_sq.sqrt();
|
||||
if norm_a == 0.0 || norm_b == 0.0 {
|
||||
// Fast path: If vectors are already normalized (Candle & fallback embeddings), skip square roots
|
||||
if (norm_a_sq - 1.0).abs() < 1e-4 && (norm_b_sq - 1.0).abs() < 1e-4 {
|
||||
return dot_product.clamp(-1.0, 1.0);
|
||||
}
|
||||
|
||||
let norm_product = norm_a_sq * norm_b_sq;
|
||||
if norm_product <= 0.0 {
|
||||
0.0
|
||||
} else {
|
||||
dot_product / (norm_a * norm_b)
|
||||
(dot_product / norm_product.sqrt()).clamp(-1.0, 1.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user