From 1d962230394dd4a28d315d58e04746901d9c213a Mon Sep 17 00:00:00 2001 From: tatavishnurao Date: Tue, 19 May 2026 18:19:59 +0530 Subject: [PATCH] fix: align local_knowledge_search notebook with sochdb SDK v0.5.7 API 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 --- 0_local_knowledge_search_walkthrough.ipynb | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/0_local_knowledge_search_walkthrough.ipynb b/0_local_knowledge_search_walkthrough.ipynb index 65a4f1e..c60f849 100644 --- a/0_local_knowledge_search_walkthrough.ipynb +++ b/0_local_knowledge_search_walkthrough.ipynb @@ -40,7 +40,7 @@ "from pathlib import Path\n", "\n", "import numpy as np\n", - "from sochdb import Database, HnswIndex" + "from sochdb import Database, VectorIndex" ] }, { @@ -198,9 +198,9 @@ ] } ], - "source": [ - "index = HnswIndex(dimension=DIMENSION, m=16, ef_construction=100, metric='cosine')\n", - "inserted = index.insert_batch_with_ids(ids, vectors)\n", +"source": [ + "index = VectorIndex(dimension=DIMENSION, max_connections=16, ef_construction=100)\n", + "inserted = index.insert_batch(ids, vectors)\n", "print(f'Indexed {inserted} document embeddings')" ] }, @@ -247,13 +247,15 @@ "output_type": "execute_result" } ], - "source": [ - "query = 'How do I access internal tools securely from my laptop?'\n", - "query_vec = embed_text(query)\n", - "result_ids, distances = index.search(query_vec, k=3)\n", - "\n", - "results = []\n", - "for doc_id, distance in zip(result_ids.tolist(), distances.tolist()):\n", +"source": [ + "query = 'How do I access internal tools securely from my laptop?'\n", + "query_vec = embed_text(query)\n", + "results = index.search(query_vec, k=3)\n", + "result_ids = [r[0] for r in results]\n", + "distances = [r[1] for r in results]\n", + "\n", + "results = []\n", + "for doc_id, distance in zip(result_ids, distances):\n", " payload = db.get(f'docs/{doc_id}'.encode('utf-8'))\n", " if payload is None:\n", " continue\n",