MCPcopy Create free account
hub / github.com/bcefghj/smart-cs-multi-agent / save

Method save

python-impl/memory/long_term.py:139–148  ·  view source on GitHub ↗

持久化索引到磁盘

(self)

Source from the content-addressed store, hash-verified

137 return [doc for _, doc in scored[:top_k]]
138
139 def save(self):
140 """持久化索引到磁盘"""
141 self.index_path.parent.mkdir(parents=True, exist_ok=True)
142
143 if self._index is not None:
144 faiss.write_index(self._index, str(self.index_path))
145
146 metadata_path = self.index_path.with_suffix(".meta.json")
147 with open(metadata_path, "w", encoding="utf-8") as f:
148 json.dump(self._documents, f, ensure_ascii=False, indent=2)
149
150 def load_knowledge_base(self, kb_dir: str) -> int:
151 """从目录批量加载知识库文档"""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected