MCPcopy Index your code
hub / github.com/abetlen/llama-cpp-python / save

Method save

examples/server/server.py:10484–10501  ·  view source on GitHub ↗
(self, key: str, embeddings: np.ndarray)

Source from the content-addressed store, hash-verified

10482 return MTMDEmbedding(key=key, embeddings=embeddings.astype(np.float32, copy=False))
10483
10484 def save(self, key: str, embeddings: np.ndarray) -> None:
10485 if self.max_bytes == 0:
10486 return
10487 tmp_path = self.path / f".{key}.{uuid.uuid4().hex}.tmp"
10488 final_path = self._path_for_key(key)
10489 metadata = {
10490 "version": self._metadata_version,
10491 "model": self.model_fingerprint,
10492 "mmproj": self.mmproj_fingerprint,
10493 "key": key,
10494 }
10495 self._save_file(
10496 {"embeddings": np.ascontiguousarray(embeddings, dtype=np.float32)},
10497 tmp_path,
10498 metadata,
10499 )
10500 os.replace(tmp_path, final_path)
10501 self.evict_if_needed()
10502
10503 def evict_if_needed(self) -> None:
10504 if self.max_bytes <= 0:

Callers

nothing calls this directly

Calls 3

_path_for_keyMethod · 0.95
_save_fileMethod · 0.95
evict_if_neededMethod · 0.95

Tested by

no test coverage detected