Metadata-Version: 2.4
Name: smara-crewai
Version: 0.1.0
Summary: CrewAI integration for Smara Memory API — persistent memory for AI agents
Project-URL: Homepage, https://smara.io
Project-URL: Documentation, https://api.smara.io/docs/
Project-URL: Repository, https://github.com/smara-io/crewai
Project-URL: Issues, https://github.com/smara-io/crewai/issues
Author-email: Smara <hello@smara.io>
License-Expression: MIT
Keywords: ai-agents,crewai,llm,memory,smara
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: crewai>=0.80.0
Requires-Dist: httpx>=0.27.0
Description-Content-Type: text/markdown

# smara-crewai

CrewAI integration for the [Smara Memory API](https://smara.io) -- persistent, semantic memory for AI agents.

## Install

```bash
pip install smara-crewai
```

## Quick start

### 1. Memory backend (automatic)

Plug `SmaraMemory` into CrewAI so all agent memory is automatically persisted and retrieved via Smara.

```python
import os
from crewai import Agent, Crew, Task
from smara_crewai import SmaraMemory

os.environ["SMARA_API_KEY"] = "smara_..."

crew = Crew(
    agents=[
        Agent(
            role="Researcher",
            goal="Find and remember key facts",
            backstory="You are a diligent research assistant.",
        )
    ],
    tasks=[
        Task(
            description="Research the latest AI memory techniques.",
            expected_output="A summary of techniques.",
        )
    ],
    memory=True,
    memory_config={
        "provider": SmaraMemory(user_id="research-session"),
    },
)

crew.kickoff()
```

Every memory created during the run is stored in Smara. On the next run (even from a different machine), the same memories are available.

### 2. Agent tools (explicit)

Give agents `SmaraStoreTool` and `SmaraSearchTool` so they can decide when to remember or recall information.

```python
from crewai import Agent
from smara_crewai import SmaraStoreTool, SmaraSearchTool

store = SmaraStoreTool(user_id="customer-support")
search = SmaraSearchTool(user_id="customer-support")

agent = Agent(
    role="Support Agent",
    goal="Help customers and remember their preferences",
    backstory="You are a helpful support agent with long-term memory.",
    tools=[store, search],
)
```

The agent will autonomously call `smara_store_memory` when it learns something important and `smara_search_memory` when it needs past context.

### 3. Direct client usage

```python
from smara_crewai.client import SmaraClient

client = SmaraClient(api_key="smara_...")

# Store
client.store(user_id="u1", fact="User prefers dark mode", importance=0.7)

# Search
results = client.search(user_id="u1", query="UI preferences")
for mem in results:
    print(mem["fact"], mem.get("score"))

# User context
ctx = client.get_context(user_id="u1")
print(ctx)
```

## Configuration

| Parameter | Env var | Default |
|-----------|---------|---------|
| `api_key` | `SMARA_API_KEY` | *(required)* |
| `base_url` | `SMARA_API_URL` | `https://api.smara.io` |
| `user_id` | -- | `"default"` |

## API reference

### SmaraMemory (Storage backend)

- `save(value, metadata=None)` -- store a memory (called automatically by CrewAI)
- `search(query, limit=5, score_threshold=0.0)` -- retrieve relevant memories

### SmaraStoreTool

Agent tool to store a memory. Accepts `fact` (str) and `importance` (float 0-1).

### SmaraSearchTool

Agent tool to search memories. Accepts `query` (str) and `limit` (int 1-50).

## Links

- [Smara API docs](https://api.smara.io/docs/)
- [Smara website](https://smara.io)
- [CrewAI docs](https://docs.crewai.com)
