| 159 | |
| 160 | #[tokio::test] |
| 161 | async fn test_vector_index_update() { |
| 162 | let index = VectorIndex::new(); |
| 163 | let id = MemoryId::new(); |
| 164 | |
| 165 | index.insert(id.clone(), vec![1.0, 0.0, 0.0]).await; |
| 166 | |
| 167 | // Update embedding |
| 168 | index.update(&id, vec![0.0, 1.0, 0.0]).await; |
| 169 | |
| 170 | // Now id should be similar to [0, 1, 0] rather than [1, 0, 0] |
| 171 | let results = index |
| 172 | .search(&[0.0, 1.0, 0.0], 10, 0.5) |
| 173 | .await |
| 174 | .expect("search ok"); |
| 175 | assert_eq!(results.len(), 1); |
| 176 | assert!((results[0].1 - 1.0).abs() < 0.01); |
| 177 | } |
| 178 | |
| 179 | #[tokio::test] |
| 180 | async fn test_vector_index_clear() { |