()
| 49 | |
| 50 | |
| 51 | def _load_store() -> IndexStore: |
| 52 | global _STORE |
| 53 | if _STORE is not None: |
| 54 | return _STORE |
| 55 | |
| 56 | index_dir = _get_index_dir() |
| 57 | manifest = json.loads((index_dir / "manifest.json").read_text(encoding="utf-8")) |
| 58 | |
| 59 | chunks: list[dict[str, Any]] = [] |
| 60 | with (index_dir / "chunks.jsonl").open("r", encoding="utf-8") as f: |
| 61 | for line in f: |
| 62 | chunks.append(json.loads(line)) |
| 63 | |
| 64 | embeddings = np.load(index_dir / "embeddings.npy") |
| 65 | chunk_id_to_idx = {c["chunk_id"]: i for i, c in enumerate(chunks)} |
| 66 | |
| 67 | _STORE = IndexStore( |
| 68 | index_dir=index_dir, |
| 69 | chunks=chunks, |
| 70 | embeddings=embeddings, |
| 71 | manifest=manifest, |
| 72 | chunk_id_to_idx=chunk_id_to_idx, |
| 73 | ) |
| 74 | return _STORE |
| 75 | |
| 76 | |
| 77 | def _load_model(model_name: str): |
no test coverage detected