Skip to main content

LlamaIndex VectorStore adapter for skeg.

Project description

skeg-llamaindex

LlamaIndex VectorStore adapter for skeg. Compatible with llama-index-core >= 0.10.

Install

pip install skeg-llamaindex

Pulls in skeg (Python client) and llama-index-core automatically. Server install (skeg engine) is separate:

brew tap skegdb/tap
brew install skeg

Usage

from llama_index.core import VectorStoreIndex, StorageContext, Document
from llama_index.core.node_parser import SentenceSplitter
from skeg_llamaindex import SkegVectorStore

# 1. Start a skeg server:
#    skeg --data-dir ./data --addr 127.0.0.1:7379

# 2. Point the adapter at it. `dim` must match the embedding model.
store = SkegVectorStore.from_uri(
    "skeg://127.0.0.1:7379/notes",
    dim=1024,             # mxbai-embed-large-v1 dimension
    kind="int8",          # tier-1 quantisation
    backend="flat",       # in-RAM flat index for <50K vectors
)

# 3. Wire into LlamaIndex.
ctx = StorageContext.from_defaults(vector_store=store)
docs = [Document(text="hello world"), Document(text="goodbye world")]
index = VectorStoreIndex.from_documents(docs, storage_context=ctx)

# 4. Query as usual.
engine = index.as_query_engine()
print(engine.query("what does the first doc say?"))

Index backend choice

Use case backend Notes
Personal AI, < 50K nodes flat Exhaustive scan; fast on M-series CPUs
RAG over a fixed corpus, > 50K nodes disk_vamana (pre-build) Use skeg-cli build, then serve read-only
Streaming insert with eventual large size disk_vamana (RW) Delta WAL handles streaming

For the pre-build path, build offline once and start the server in serve mode; this adapter then queries it read-only:

# Build the index offline (one shell):
skeg-cli build --input embeddings.npy --output ./data --name notes

# Serve it read-only (another shell):
skeg --mode serve --data-dir ./data --tier pq:128:256

What this adapter handles

  • add(nodes): VSET each embedding + KV-store the text + metadata
  • query(VectorStoreQuery): VSEARCH top-k, returns node_ids + similarity
  • delete(ref_doc_id): VDEL + drop KV keys
  • Stable mapping node_id (str) → vec_id (u64) via xxh3

What this adapter does not do

  • Metadata filter pushdown: LlamaIndex post-filters returned hits.
  • Batched VSET: one VSET per node on the synchronous path. For large corpora build the index offline with skeg-cli build and serve it read-only.
  • Hybrid sparse+dense search: skeg's surface is dense-only.
  • Async API: this adapter is synchronous.

Test-suite safety

The pytest suite spawns its own skeg-server via the conftest fixture and tears it down at the end. The tests create VINDEX entries with names like notes-<test_name> and drop them after each test. If you ever override the fixture to point at an external server, those VINDEX names may collide with yours. The fixture is the safe default.

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skeg_llamaindex-0.1.1.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skeg_llamaindex-0.1.1-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file skeg_llamaindex-0.1.1.tar.gz.

File metadata

  • Download URL: skeg_llamaindex-0.1.1.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for skeg_llamaindex-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d0e8ec885f0014e3b24c3d730ce3fae1ebd0f7bdff91bdffc4de55e63400664c
MD5 1c58474039854f88c18b294ac1143305
BLAKE2b-256 5ea5288591bc1ac80f22c52673ec7be547abbcb79e245be8b48240dc1f43facb

See more details on using hashes here.

File details

Details for the file skeg_llamaindex-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for skeg_llamaindex-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5be38b0f1cb9938d309511503ef9b35f2fbd1ed5cb5f1d64506faa1c26889c2
MD5 6769ec82a8e3b51657b52848b75c79c2
BLAKE2b-256 da163b61d0ad0c3f076886bd78a65f933cd8530463844d6fe0c259b92e69aac3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page