(self, other: Self, deps: Deps)
| 130 | ) |
| 131 | |
| 132 | async def merge_with(self, other: Self, deps: Deps): |
| 133 | self.content = await do_ai( |
| 134 | f"{self.content}\n\n{other.content}", |
| 135 | "Combine the following two texts into a single, coherent text.", |
| 136 | str, |
| 137 | deps, |
| 138 | ) |
| 139 | self.importance += other.importance |
| 140 | self.access_count += other.access_count |
| 141 | self.embedding = [(a + b) / 2 for a, b in zip(self.embedding, other.embedding)] |
| 142 | self.summary = await do_ai(self.content, "Summarize the following text concisely.", str, deps) |
| 143 | await self.save(deps) |
| 144 | # Delete the merged node from the database |
| 145 | if other.id is not None: |
| 146 | await delete_memory(other.id, deps) |
| 147 | |
| 148 | def get_effective_importance(self): |
| 149 | return self.importance * (1 + math.log(self.access_count + 1)) |
no test coverage detected