Metadata-Version: 2.4
Name: skeg-ollama
Version: 0.1.0
Summary: Ollama-based embedding + retrieval pipeline backed by skeg.
Author: skeg contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/skegdb/skeg-ollama
Project-URL: Repository, https://github.com/skegdb/skeg-ollama
Keywords: ollama,embeddings,vector-store,skeg,rag,local-ai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
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
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: skeg<0.2,>=0.1.0
Requires-Dist: ollama>=0.3
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Requires-Dist: pytest-timeout>=2.0; extra == "test"
Requires-Dist: numpy>=1.24; extra == "test"
Dynamic: license-file

# skeg-ollama

Ollama-backed embedding + retrieval pipeline using [skeg](https://github.com/skegdb/skeg).
Two helpers: `OllamaEmbedder` (thin embeddings wrapper) and
`OllamaRetriever` (end-to-end embed + store + search). A
two-files-of-code path to "I have Ollama running locally, give me a
vector DB that does not eat my LLM's RAM."

## Install

```sh
pip install skeg-ollama
```

Pulls in `skeg` (Python client) and `ollama` automatically. Server +
daemon install is separate:

```sh
brew tap skegdb/tap && brew install skeg   # skeg server
ollama serve                               # Ollama daemon
ollama pull nomic-embed-text               # embedding model
skeg --data-dir ./data                     # the KV+vector backend
```

## Usage

```python
from skeg_ollama import OllamaRetriever

with OllamaRetriever(
    skeg_addr=("127.0.0.1", 7379),
    index_name="my-notes",
    ollama_model="nomic-embed-text",
) as r:
    r.add([
        "the sky is blue",
        "grass is green",
        "cats are fluffy",
    ])
    for text, score in r.search("what colour is the sky?", k=2):
        print(f"  {score:.3f}  {text}")
```

Output (roughly):

```text
  0.812  the sky is blue
  0.124  grass is green
```

## Persistence

The retriever's vec_id counter is persisted under the skeg KV side at
`next-id:{index_name}`, so restarting the process keeps the numbering
monotonic. The VINDEX itself is persisted via skeg's normal disk path
(`vindex-<name>/` directory).

## When to use this vs skeg-llamaindex

- Use **skeg-ollama** when you want a tiny, transparent retrieval loop
  with full control: 200 lines of code top to bottom, no framework.
- Use **skeg-llamaindex** when you want LlamaIndex's full surface:
  document chunking, metadata filters, query engines, response synthesis.

## Test-suite safety

The pytest suite spawns its own skeg-server fixture. Tests create
VINDEX entries with names like `ollama-test`, `ollama-batch-...`,
`ollama-empty` etc., and drop them at the end. The counter key
`next-id:<index_name>` is left as forensic data after each test
drop. If you ever override the fixture to hit an external server,
expect those names to collide. The fixture is the safe default.

## License

Apache-2.0.
