Metadata-Version: 2.4
Name: beeai-framework-engram
Version: 0.1.0
Summary: Engram memory integration for the BeeAI framework — durable, explainable memory for agents.
Project-URL: Homepage, https://lumetra.io
Project-URL: Documentation, https://lumetra.io/docs
Project-URL: Repository, https://github.com/lumetra-io/engram-beeai
Project-URL: Issues, https://github.com/lumetra-io/engram-beeai/issues
Author-email: Lumetra <hi@lumetra.io>
License: MIT License
        
        Copyright (c) 2026 Lumetra
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: agents,beeai,beeai-framework,engram,llm,lumetra,memory
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.11
Requires-Dist: beeai-framework<0.2,>=0.1.50
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# beeai-framework-engram

Engram memory integration for the [BeeAI framework](https://github.com/i-am-bee/beeai-framework).

`EngramMemory` is a `BaseMemory` implementation that persists every chat message your agent sees to [Engram](https://lumetra.io) — Lumetra's durable, explainable memory service. Messages survive process restarts, are searchable via the Engram API, and can be cleared per-bucket.

## Install

```bash
pip install beeai-framework-engram
```

## Quick start

```python
import asyncio
import os

from beeai_framework.backend.message import UserMessage, AssistantMessage
from beeai_framework_engram import EngramMemory

os.environ["ENGRAM_API_KEY"] = "eng_live_..."  # or pass api_key=... below

async def main() -> None:
    memory = EngramMemory(bucket="my-agent")
    await memory.add(UserMessage("My favorite color is blue."))
    await memory.add(AssistantMessage("Got it, I'll remember that."))

    # Restart the process — messages are still there.
    fresh = EngramMemory(bucket="my-agent")
    print([m.text for m in fresh.messages])

asyncio.run(main())
```

## With a BeeAI agent

```python
import asyncio
import os

from beeai_framework.agents.react import ReActAgent
from beeai_framework.backend.chat import ChatModel
from beeai_framework.tools.search.duckduckgo import DuckDuckGoSearchTool
from beeai_framework_engram import EngramMemory

async def main() -> None:
    llm = ChatModel.from_name("ollama:granite3.3:8b")
    agent = ReActAgent(
        llm=llm,
        tools=[DuckDuckGoSearchTool()],
        memory=EngramMemory(bucket="my-react-agent"),
    )
    result = await agent.run("What did we talk about last time?")
    print(result.result.text)

asyncio.run(main())
```

## Configuration

| Argument | Env var | Default | Notes |
|---|---|---|---|
| `bucket` | — | `"default"` | Engram bucket name. Pick one per agent / per user. |
| `api_key` | `ENGRAM_API_KEY` | — | Required. |
| `base_url` | `ENGRAM_BASE_URL` | `https://api.lumetra.io` | Override for self-hosted. |
| `hydrate` | — | `True` | Load existing memories from the bucket on construction. |
| `hydrate_limit` | — | `200` | Cap on hydrated messages. |
| `timeout` | — | `30.0` | HTTP timeout (seconds). |

## API reference

`EngramMemory` implements the full `BaseMemory` contract: `messages`, `add`, `delete`, `reset`, `add_many`, `delete_many`, `splice`, `is_empty`, `clone`, and `as_read_only`. It also exposes:

- `await memory.query("...")` — ask Engram a question over this bucket; returns the raw JSON response (`{success, answer, ...}`).
- `memory.bucket`, `memory.base_url` — read-only accessors.

`reset()` clears the entire Engram bucket — use a per-agent / per-user bucket name to avoid wiping shared memory.

## Privacy

See [PRIVACY.md](./PRIVACY.md). The integration only talks to the Engram base URL you configured; no other services are contacted.

## License

MIT — see [LICENSE](./LICENSE).
