MCPcopy Index your code
hub / github.com/OpenBMB/ChatDev / save

Method save

runtime/node/agent/memory/file_memory.py:72–95  ·  view source on GitHub ↗

Persist the memory index to disk

(self)

Source from the content-addressed store, hash-verified

70 self.save()
71
72 def save(self) -> None:
73 """Persist the memory index to disk"""
74 if not self.index_path:
75 logger.warning("No index_path specified, skipping save")
76 return
77
78 # Ensure directory exists
79 os.makedirs(os.path.dirname(self.index_path), exist_ok=True)
80
81 # Prepare data for serialization
82 data = {
83 "file_metadata": self.file_metadata,
84 "contents": [item.to_dict() for item in self.contents],
85 "config": {
86 "chunk_size": self.chunk_size,
87 "chunk_overlap": self.chunk_overlap,
88 }
89 }
90
91 # Save to JSON
92 with open(self.index_path, 'w', encoding='utf-8') as f:
93 json.dump(data, f, indent=2, ensure_ascii=False)
94
95 logger.info(f"Index saved to {self.index_path} ({len(self.contents)} chunks)")
96
97 def retrieve(
98 self,

Callers 2

loadMethod · 0.95
_save_memoriesMethod · 0.45

Calls 3

warningMethod · 0.45
to_dictMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected