def save(self, save_dir="faiss"): """Save FAISS index to disc Args: save_dir (str, optional): Directory to save FAISS index. Defaults to "faiss". """ mkdir(save_dir) faiss.write_index(self.index, os.path.join(save_dir, "faiss.index")) save_json_file(os.path.join(save_dir, "faiss.map"), self.id_map)
def update(self, value): self._cache.update(value) save_json_file(self._cache_file, self._cache)
def __delitem__(self, key): if key not in self._cache: raise KeyError del self._cache[key] save_json_file(self._cache_file, self._cache)
def __setitem__(self, key, value): self._cache[key] = value save_json_file(self._cache_file, self._cache)