Skip to content

Fix local knowledge search notebook API drift against SDK v0.5.7#3

Open
tatavishnurao wants to merge 1 commit into
sochdb:mainfrom
tatavishnurao:fix/notebook-api-drift
Open

Fix local knowledge search notebook API drift against SDK v0.5.7#3
tatavishnurao wants to merge 1 commit into
sochdb:mainfrom
tatavishnurao:fix/notebook-api-drift

Conversation

@tatavishnurao
Copy link
Copy Markdown

Fix notebook API drift against sochdb==0.5.7

Summary

This PR updates 0_local_knowledge_search_walkthrough.ipynb to use the current public SochDB Python SDK API.

The notebook was still using the older/internal HNSW-facing API shape:

  • HnswIndex
  • m=...
  • metric=...
  • insert_batch_with_ids(...)
  • search(...) unpacked as (ids, distances)

The current SDK exposes the vector index through VectorIndex, with batch insertion via insert_batch(...), and search(...) returning a list of (id, distance) tuples.

Changes

1. Replace HnswIndex import with VectorIndex

from sochdb import Database, VectorIndex

instead of:

from sochdb import Database, HnswIndex

2. Update vector index construction

index = VectorIndex(
    dimension=DIMENSION,
    max_connections=16,
    ef_construction=100,
)

instead of using the older constructor shape with m / metric.

3. Update batch insertion API

inserted = index.insert_batch(ids, vectors)

instead of:

inserted = index.insert_batch_with_ids(ids, vectors)

4. Update search result handling

VectorIndex.search(...) returns:

List[Tuple[int, float]]

So the notebook now normalizes results like this:

search_results = index.search(query_vec, k=3)

result_ids = [r[0] for r in search_results]
distances = [r[1] for r in search_results]

instead of unpacking search output as two separate arrays.

5. Remove non-existent package install cell

Removed the !uv pip install sochdb-hnswindex cell since that package does not exist on PyPI. The HNSW vector index is included in the base sochdb package.

Why

The notebook currently fails for users running against the public SDK because it references API members that are not exposed by sochdb==0.5.7.

This PR keeps the walkthrough aligned with the SDK surface area and makes the notebook runnable for users following the repository instructions.

Verification

Verified the SDK export surface:

python -c "import sochdb; print([x for x in dir(sochdb) if 'Index' in x])"

Expected output:

['VectorIndex']

Also verified the vector module exposes the expected index implementation:

python -c "import sochdb.vector as v; print([x for x in dir(v) if not x.startswith('_')])"

Expected to include:

VectorIndex
BatchAccumulator

Files changed

File Change
0_local_knowledge_search_walkthrough.ipynb Update notebook code cells to current SDK API

Notes

This does not change notebook behavior or the underlying indexing algorithm. The HNSW implementation is still used under the hood; the public Python API exposes it as VectorIndex.

Replace stale API references in 0_local_knowledge_search_walkthrough.ipynb:

- HnswIndex -> VectorIndex
- m= -> max_connections=
- metric= kwarg removed (not a constructor param)
- insert_batch_with_ids() -> insert_batch()
- search() returns List[Tuple[int,float]], not two arrays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant