Replace the embedding for an existing memory.
(&self, memory_id: &MemoryId, embedding: Vec<f32>)
| 78 | |
| 79 | /// Replace the embedding for an existing memory. |
| 80 | pub async fn update(&self, memory_id: &MemoryId, embedding: Vec<f32>) { |
| 81 | let mut entries = self.entries.write().await; |
| 82 | if let Some(entry) = entries.iter_mut().find(|e| &e.memory_id == memory_id) { |
| 83 | entry.embedding = embedding; |
| 84 | } else { |
| 85 | entries.push(VectorEntry { |
| 86 | memory_id: memory_id.clone(), |
| 87 | embedding, |
| 88 | }); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | /// Remove all entries from the index. |
| 93 | pub async fn clear(&self) { |