Metadata-Version: 2.1
Name: vernkv
Version: 1.0.0.post1
Summary: Zero-dependency Python SDK & high-speed local vector RAG database powered by VernKV
License: Apache-2.0
Requires-Python: >=3.9
Project-URL: Homepage, https://github.com/ver1619/VERN_KV
Project-URL: Repository, https://github.com/ver1619/VERN_KV
Project-URL: Documentation, https://github.com/ver1619/VERN_KV/blob/main/notes/index.md
Project-URL: Issues, https://github.com/ver1619/VERN_KV/issues
Keywords: database,lsm-tree,vector,rag,ai,cache,kv
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Description-Content-Type: text/markdown

# VernKV Python SDK (`vernkv`)

<p align="center">
  <img src="https://raw.githubusercontent.com/ver1619/VERN_KV/main/logo.jpg" alt="VernKV logo" width="260">
</p>

Zero-dependency Python SDK and local **LSM-Tree Key-Value & Vector Search Database** for **Linux (`x86_64` / `aarch64`)** and **Windows (`amd64`)**, bundling a standalone pure-Go `vernkv-server` binary inside every wheel.

---

## Installation

```bash
pip install vernkv
# or with uv:
uv add vernkv
```

No Go compiler or external Python dependencies are required.

---

## Architecture

```text
Python Client (VernKV / VernKVStore / SemanticCache / ConversationMemory)
   ├── Binary RESP2 TCP (hot path: put / get / delete / vadd / vsearch)
   └── HTTP JSON REST   (admin / batch / scan / health)
          │
          ▼
Bundled Go Server (vernkv-server)
   ├── Core LSM-Tree Engine (WAL Group Commit -> MemTable -> L0..L6 SSTables + MANIFEST)
   └── Pure-Go Vector Index (Flat & HNSW + atomic _vec: / _vmeta: / _vdoc: batches)
```

---

## Quick Start

### 1. Local Embedded KV + TTL + Prefix Scan

```python
from vernkv import VernKV

with VernKV.local("./data/my_db", sync_writes=False) as db:
    db.put("user:1:role", "admin")
    db.put("session:tmp", "token", ttl_seconds=3600)

    print(db.get("user:1:role"))          # -> "admin"
    print(db.scan(prefix="user:", limit=10))
```

### 2. Hybrid Vector RAG (`VernKVStore`)

Combine dense similarity search (`flat` or `hnsw`, `cosine` / `dot` / `l2`) with metadata filters:

```python
from vernkv import VernKV, VernKVStore

with VernKV.local("./data/rag_db", sync_writes=False) as db:
    store = VernKVStore(db, index="docs", embed_fn=my_embed_fn, index_type="hnsw")
    store.add_texts(
        ["VernKV persists vectors atomically in SSTables."],
        metadatas=[{"source": "arch.md", "page": 1}],
        ids=["chunk-1"],
    )
    hits = store.search(
        "How are vectors stored?",
        top_k=5,
        filter={"source": "arch.md", "page": {"$gte": 1}},
    )
    for hit in hits:
        print(hit.id, hit.score, hit.meta, hit.doc)
```

### 3. Semantic Prompt Cache & Conversation Memory

```python
from vernkv import ConversationMemory, SemanticCache, VernKV

with VernKV.local("./data/ai_db", sync_writes=False) as db:
    cache = SemanticCache(db, embed_fn=my_embed_fn, threshold=0.95, ttl_seconds=600)
    cache.store("Explain WAL compaction", "WAL truncates after MemTable flush.")
    print(cache.lookup("How does WAL compaction work?"))

    mem = ConversationMemory(db, session_id="thread-42", ttl_seconds=86400)
    mem.append("user", "Hello!")
    mem.append("assistant", "Hi, how can I help?")
    print(mem.messages(limit=20))
```

### 4. Connect to a Remote `vernkv-server`

```python
from vernkv import VernKV

with VernKV(
    "http://127.0.0.1:8080",
    resp_addr="127.0.0.1:6379",
    username="admin",
    password="StrongPassword123!",
) as db:
    print(db.health())
```

You can also launch the bundled server directly from your shell:

```bash
vernkv-server --help
```

---

## Documentation & Links

- **[Full Documentation Hub](https://github.com/ver1619/VERN_KV/blob/main/notes/index.md)** — complete architecture, storage engine internals, and user guides
- **[Python AI SDK Guide](https://github.com/ver1619/VERN_KV/blob/main/notes/vern/python_sdk.md)** — embedding provider snippets (`sentence-transformers`, OpenAI, Ollama) and full examples
- **[Hands-On Python Walkthroughs](https://github.com/ver1619/VERN_KV/blob/main/notes/dev-test/vern_ai.md)** — runnable `uv` workspace examples
- **[GitHub Repository](https://github.com/ver1619/VERN_KV)** · **[License (Apache-2.0)](https://github.com/ver1619/VERN_KV/blob/main/LICENSE)** · **[ver1619/itFrame](https://github.com/ver1619/itFrame)**
