Skip to main content

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:ingest and /v1/memories:search (FastAPI) using canonical Scope, MemoryItem schemas.
  • 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

  1. Python env
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
  1. Config
    Use config.example.yaml as a template; set MEMORY_ENGINE_CONFIG to your config path. 默认 token: demo-token 绑定 tenant_id=demo-tenant, app_id=demo-app
    也可通过环境变量覆盖:PROVIDER_KINDMEM0_API_KEYMEM0_BASE_URL(自建 Mem0 时指向你的服务地址)、MEM0_TIMEOUT_SECONDSRATE_LIMIT_DEFAULT_PER_MINUTEIDEMPOTENCY_TTL_SECONDS
  2. Run
uvicorn memory_engine.main:app --reload
  1. 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_secondsmem0_max_retriesmem0_backoff_seconds

API 契约与错误码

  • 详见 docs/api_contract.mddocs/error_codes.md;OpenAPI 可通过运行后访问 /docs

Notes for next iterations

  • Swap InMemoryProvider with 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memory_engine_adapters-0.2.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memory_engine_adapters-0.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

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

Hashes for memory_engine_adapters-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0dbfa4f75eb0ea058b9de602c9bc15ca50cde6a572e0b9421c812b717a53fc29
MD5 223b126123cee6c9748e2a1bf1ae0572
BLAKE2b-256 074ee13d40439ae638b8b15dc22efbef446501fda13e27f6ea8b0d795dd21344

See more details on using hashes here.

File details

Details for the file memory_engine_adapters-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for memory_engine_adapters-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 993db8981dcd95c9e6ea70dce84c3f6fc0f17e5d1a7182815825a03bc7a41e71
MD5 64790230825624e05595b87e8f1847f0
BLAKE2b-256 6834edccc56d25363ff8eb776233f42ffdda8b46f6e6f4dc7679491c3d9bb1a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page