Use this file to discover all available pages before exploring further.
What this builds. A KB that mirrors a nested local folder — subfolders become KB folders, files become KB items.
You’ll end up with. A completed ingestion task whose KB layout matches the on-disk layout, verified by list_items.
"""Example 03: Upload a local folder, preserving directory structure.`kb.add_folder(...)` walks the local directory, builds a nested foldertree, and submits a single ingestion request. The KB layout will mirrorthe local layout.Requires the v1 ingestion task endpoints + folder-tree extension toKbIndexRequest (M2 [A2])."""import tempfilefrom pathlib import Pathfrom vectorshift.knowledge_base import KnowledgeBase# Build a small nested folderwith tempfile.TemporaryDirectory() as tmp: root = Path(tmp) / "handbook" (root / "policies").mkdir(parents=True) (root / "policies" / "pto.md").write_text("# PTO\n\n- 20 days/yr\n") (root / "policies" / "remote.md").write_text("# Remote\n\nWFH OK.\n") (root / "engineering").mkdir() (root / "engineering" / "oncall.md").write_text("# Oncall\n\nWeekly rotation.\n") (root / "README.md").write_text("# Handbook\n\nWelcome.\n") kb = KnowledgeBase.new(name="SDK folder demo") print(f"1. Created KB id={kb.id}") final = kb.add_folder_and_wait(root, timeout=180) print( f"2. Folder ingest completed: status={final.status} " f"items={len(final.item_ids)}" ) # List items to confirm folder hierarchy is preserved items = kb.list_items(limit=50) print(f"3. Items in KB: {len(items)}") kb.delete() print("4. Deleted KB.")