mirror of
https://github.com/VectifyAI/PageIndex.git
synced 2026-06-24 20:28:12 +02:00
fix(filesystem): guard summary index dimensions
Raise on summary projection dimension mismatch instead of resetting an existing index.
This commit is contained in:
parent
2297453103
commit
cb9db0bab9
2 changed files with 61 additions and 9 deletions
|
|
@ -110,15 +110,20 @@ class SummaryProjectionIndexer:
|
|||
)
|
||||
return
|
||||
try:
|
||||
if self.index.dimension() != self.embedding_dimensions:
|
||||
self.index.reset(
|
||||
dimension=self.embedding_dimensions,
|
||||
metadata=self._index_metadata(),
|
||||
)
|
||||
except Exception:
|
||||
self.index.reset(
|
||||
dimension=self.embedding_dimensions,
|
||||
metadata=self._index_metadata(),
|
||||
existing_dimension = self.index.dimension()
|
||||
except Exception as exc:
|
||||
raise RuntimeError(
|
||||
"could not validate existing summary projection index config; "
|
||||
f"refusing to reset {self.index.db_path}. Move the existing index "
|
||||
"aside or rebuild it intentionally before changing embedding config."
|
||||
) from exc
|
||||
if existing_dimension != self.embedding_dimensions:
|
||||
raise RuntimeError(
|
||||
"summary projection index dimension mismatch: "
|
||||
f"{self.index.db_path} was built with dimension {existing_dimension}, "
|
||||
f"but configured embedding_dimensions is {self.embedding_dimensions}. "
|
||||
"Use the matching embedding config, or rebuild the projection index "
|
||||
"at a new path after preserving the existing data."
|
||||
)
|
||||
|
||||
def _index_metadata(self) -> dict[str, Any]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue