Metadata-Version: 2.4
Name: kemi
Version: 0.1.1
Summary: Persistent memory for AI agents. Three methods. Zero infra.
Project-URL: Homepage, https://usekemi.com
Project-URL: Repository, https://github.com/alokvadera/kemi
Project-URL: Issues, https://github.com/alokvadera/kemi/issues
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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 :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Provides-Extra: all
Requires-Dist: fastembed>=0.2.0; extra == 'all'
Requires-Dist: openai>=1.0.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Provides-Extra: local
Requires-Dist: fastembed>=0.2.0; extra == 'local'
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == 'openai'
Description-Content-Type: text/markdown

# kemi

Persistent memory for AI agents. Three methods. Zero infra.

```python
from kemi import Memory

memory = Memory()  # SQLite + local embeddings, no API keys needed

memory.remember("user123", "User prefers dark mode")
memory.remember("user123", "User is vegetarian")

results = memory.recall("user123", "what are the user's preferences?")
# Returns ranked, deduplicated memories

memory.forget("user123")  # GDPR-compliant deletion
```

## Install

```bash
# Zero dependencies — SQLite storage, no embedding (bring your own)
pip install kemi

# With local embeddings (no API key needed, ~130MB model download)
pip install kemi[local]

# With OpenAI embeddings
pip install kemi[openai]
```

## Why kemi

Every existing memory library either hosts your data on their servers, requires Docker and 4 services to run, or locks you into a specific framework.

kemi is different:

- **Zero infrastructure** — runs on your machine, single pip install
- **Your data** — never leaves your machine, stored in SQLite by default
- **Bring your own embedding** — OpenAI, local models, or any function
- **Framework agnostic** — works with LangChain, CrewAI, AutoGen, or plain Python
- **100% free** — MIT license, no paid tiers, no cloud lock-in

## Usage

### Zero-config (local embeddings)

```python
from kemi import Memory

memory = Memory()
memory.remember("user123", "User is vegetarian", importance=0.9)
results = memory.recall("user123", "food preferences")
```

### With OpenAI embeddings

```python
from kemi import Memory
from kemi.adapters.embedding.openai import OpenAIEmbedAdapter

memory = Memory(embed=OpenAIEmbedAdapter())
memory.remember("user123", "User prefers concise responses")
results = memory.recall("user123", "communication style")
```

### Inject into system prompt

```python
context = memory.context_block("user123", query="user preferences", max_tokens=500)
# Returns formatted string ready for system prompt injection
```

### GDPR-compliant deletion

```python
memory.forget("user123")               # Delete all memories for user
memory.forget("user123", memory_id)    # Delete one specific memory
```

## How it works

kemi sits between your agent and your storage. It handles:

- **Semantic deduplication** — "I'm vegetarian" and "I don't eat meat" are the same memory
- **Importance-weighted scoring** — recent, important memories rank higher
- **Temporal decay** — memories fade if never recalled
- **Conflict detection** — flags contradictory memories for review
- **Lifecycle management** — active → decaying → archived → deleted

## Adapters

| Type | Default | Available |
|------|---------|-----------|
| Embedding | fastembed (local) | OpenAI, custom |
| Storage | SQLite | JSON, custom |

## License

MIT — free forever, no exceptions.
