Save the contract for a memory system
(self, memory_names: Optional[List[str]] = None)
| 827 | return str(file_path) |
| 828 | |
| 829 | async def save_contract(self, memory_names: Optional[List[str]] = None): |
| 830 | """Save the contract for a memory system""" |
| 831 | contract = [] |
| 832 | if memory_names is not None: |
| 833 | for index, memory_name in enumerate(memory_names): |
| 834 | memory_info = await self.get_info(memory_name) |
| 835 | if memory_info: |
| 836 | text = f"Name: {memory_info.name}\nDescription: {memory_info.description}\nRequire Grad: {memory_info.require_grad}" |
| 837 | contract.append(f"{index + 1:04d}\n{text}\n") |
| 838 | else: |
| 839 | for index, memory_name in enumerate(self._memory_configs.keys()): |
| 840 | memory_info = await self.get_info(memory_name) |
| 841 | if memory_info: |
| 842 | text = f"Name: {memory_info.name}\nDescription: {memory_info.description}\nRequire Grad: {memory_info.require_grad}" |
| 843 | contract.append(f"{index + 1:04d}\n{text}\n") |
| 844 | contract_text = "---\n".join(contract) |
| 845 | with open(self.contract_path, "w", encoding="utf-8") as f: |
| 846 | f.write(contract_text) |
| 847 | logger.info(f"| 📝 Saved {len(contract)} memory systems contract to {self.contract_path}") |
| 848 | |
| 849 | async def load_contract(self) -> str: |
| 850 | """Load the contract for memory systems |