Metadata-Version: 2.4
Name: oliviadb-crewai
Version: 0.1.2
Summary: CrewAI memory storage backed by OliviaDB
License-Expression: Apache-2.0
Requires-Python: <3.14,>=3.10
Description-Content-Type: text/markdown
Requires-Dist: oliviadb>=0.1.0
Requires-Dist: crewai<2,>=1.15

<!-- SPDX-License-Identifier: Apache-2.0 -->
# oliviadb-crewai

[CrewAI](https://www.crewai.com/) memory storage in [OliviaDB](https://olivia-db.com/)
(`OliviaDBStorage`, the `StorageBackend` protocol of the unified `Memory`): one document per
memory record with CrewAI's embedding, scopes as namespace paths, vector search. Tested with
crewai 1.15.47 on Python 3.13.

## Install

```sh
pip install oliviadb-crewai
```

Python 3.10 to 3.13 (CrewAI's range).

## Example

A server from the core image (`docker run -d -p 8443:8443 -v oliviadb-data:/data
ghcr.io/oliviadb/oliviadb`), its API key in `OLIVIADB_API_KEY` and its certificate in
`oliviadb-ca.pem` (`docker cp <container>:/data/tls/server.pem oliviadb-ca.pem`):

```python
import hashlib
import os

from crewai.memory.unified_memory import Memory
from oliviadb import OliviaDbClient
from oliviadb_crewai import OliviaDBStorage


def embed(texts: list[str]) -> list[list[float]]:
    """Any embedder works (CrewAI's providers, or a function like this offline stand-in)."""
    out = []
    for t in texts:
        v = [0.0] * 64
        for w in t.lower().split():
            v[int(hashlib.sha1(w.encode()).hexdigest(), 16) % 64] += 1.0
        n = sum(x * x for x in v) ** 0.5 or 1.0
        out.append([x / n for x in v])
    return out


client = OliviaDbClient("https://localhost:8443", api_key=os.environ["OLIVIADB_API_KEY"], ca_file="oliviadb-ca.pem")
memory = Memory(storage=OliviaDBStorage(client, root=("crewai", "crew")), embedder=embed, llm="none")
memory.remember("The customer Acme prefers invoices in EUR.", scope="/customers/acme", categories=["billing"])
for match in memory.recall("which currency for Acme invoices", depth="shallow"):
    print(round(match.score, 3), match.record.content)
```

## Links

* Documentation: <https://docs.olivia-db.com/>
* Repository: <https://github.com/OliviaDB/oliviadb-python> (`adapters/crewai`)

Licence: Apache-2.0.
