Adapters that connect Memory Engine to external agent frameworks (e.g., Google ADK).
Project description
Memory Engine Service (MVP)
An internal-facing Memory Engine skeleton aligned with docs/design.md: unified ingest/search API, pluggable provider adapter, basic governance (auth, rate limit, audit, multi-tenant scope).
Features
/v1/memories:ingestand/v1/memories:search(FastAPI) using canonicalScope,MemoryItemschemas.- Bearer-token auth with tenant/app binding; scope enforcement per request.
- Per-tenant/app process-local rate limiting (configurable) and ingest 幂等(
Idempotency-Key)。 - Audit middleware logging trace id, tenant/app/user/agent, latency, status(幂等重放标记)。
- Provider 插槽:默认 in-memory;配置
provider.kind=mem0可启用 Mem0Adapter(需安装mem0包并提供 API Key)。
Getting started
- Python env
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
- Config
Useconfig.example.yamlas a template; setMEMORY_ENGINE_CONFIGto your config path. 默认 token:demo-token绑定tenant_id=demo-tenant,app_id=demo-app。
也可通过环境变量覆盖:PROVIDER_KIND、MEM0_API_KEY、MEM0_BASE_URL(自建 Mem0 时指向你的服务地址)、MEM0_TIMEOUT_SECONDS、RATE_LIMIT_DEFAULT_PER_MINUTE、IDEMPOTENCY_TTL_SECONDS。 - Run
uvicorn memory_engine.main:app --reload
- Smoke test
curl -X POST http://127.0.0.1:8000/v1/memories:ingest \
-H "Authorization: Bearer demo-token" \
-H "Content-Type: application/json" \
-d '{
"scope": {"tenant_id":"demo-tenant","app_id":"demo-app","user_id":"u-1"},
"mode": "raw",
"memories": [
{
"type": "fact",
"content": {"text": "Paris is the capital of France."},
"metadata": {"lang": "en"}
}
]
}'
curl -X POST http://127.0.0.1:8000/v1/memories:search \
-H "Authorization: Bearer demo-token" \
-H "Content-Type: application/json" \
-d '{
"scope": {"tenant_id":"demo-tenant","app_id":"demo-app","user_id":"u-1"},
"query": "capital of France",
"top_k": 3
}'
Provider 切换
- 默认:
provider.kind=in_memory - Mem0(包含自建):设置
provider.kind=mem0并提供mem0_api_key;自建部署请配置mem0_base_url指向你的 Mem0 服务地址,并安装mem0包。并发/持久化由 Mem0 后端负责,请不要使用单文件存储。可调mem0_timeout_seconds、mem0_max_retries、mem0_backoff_seconds。
API 契约与错误码
- 详见
docs/api_contract.md、docs/error_codes.md;OpenAPI 可通过运行后访问/docs。
Notes for next iterations
- Swap
InMemoryProviderwith Mem0 adapter; support dual-write/fallback hooks. - Move rate limiting to shared store (Redis) for multi-instance deployment.
- Extend audit with export to centralized logging and payload sampling.
- Harden auth (IAM integration, scoped signing) and finer-grained visibility rules.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file memory_engine_adapters-0.2.0.tar.gz.
File metadata
- Download URL: memory_engine_adapters-0.2.0.tar.gz
- Upload date:
- Size: 21.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0dbfa4f75eb0ea058b9de602c9bc15ca50cde6a572e0b9421c812b717a53fc29
|
|
| MD5 |
223b126123cee6c9748e2a1bf1ae0572
|
|
| BLAKE2b-256 |
074ee13d40439ae638b8b15dc22efbef446501fda13e27f6ea8b0d795dd21344
|
File details
Details for the file memory_engine_adapters-0.2.0-py3-none-any.whl.
File metadata
- Download URL: memory_engine_adapters-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
993db8981dcd95c9e6ea70dce84c3f6fc0f17e5d1a7182815825a03bc7a41e71
|
|
| MD5 |
64790230825624e05595b87e8f1847f0
|
|
| BLAKE2b-256 |
6834edccc56d25363ff8eb776233f42ffdda8b46f6e6f4dc7679491c3d9bb1a4
|