Implements the subset of the hosted mem0 platform API that mem0ai==2.0.2
MemoryClient calls, so MemoryClient(host=..., api_key=...) works against this
server. Verified end-to-end (construct/add/search/get_all/get/history/update/delete).
- platform_compat.py: GET /v1/ping/ (returns non-empty org_id/project_id, which
the SDK's Project init requires), POST /v3/memories/{add,search}/,
POST /v3/memories/ (paginated get_all), /v1/memories/{id}/ item ops, and
GET /v1/entities/ -- all mapped onto the existing mem0_manager.
- auth.get_current_user_platform: accepts Authorization: Token (mem0 SDK),
Bearer, or X-API-Key.
- main.py: include the platform router; remove the /v1/memories* aliases added
in ea07a82 (the SDK uses /v3 and trailing-slash /v1/memories/{id}/, not those
paths); keep /v1/chat/completions and the native /memories* routes.
- docker-compose: run uvicorn with --proxy-headers --forwarded-allow-ips=* so the
proxy's https scheme is honoured. This stops trailing-slash 307 redirects from
downgrading https->http and dropping the Authorization header -- the actual
cause of the reported "POST auth broken" symptom (auth was never broken).
- test_sdk_compat.py: end-to-end MemoryClient round-trip against the server.
72 lines
2.2 KiB
YAML
72 lines
2.2 KiB
YAML
services:
|
|
# Qdrant vector database for vector + sparse (BM25) storage
|
|
qdrant:
|
|
image: qdrant/qdrant:v1.18.1
|
|
container_name: mem0-qdrant
|
|
expose:
|
|
- "6333"
|
|
networks:
|
|
- mem0_network
|
|
volumes:
|
|
- qdrant_data:/qdrant/storage
|
|
command: >
|
|
sh -c "apt-get update && apt-get install -y curl && ./entrypoint.sh"
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:6333/"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: unless-stopped
|
|
|
|
# Backend API service
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: mem0-backend
|
|
environment:
|
|
OPENAI_API_KEY: ${OPENAI_COMPAT_API_KEY}
|
|
OPENAI_BASE_URL: ${OPENAI_COMPAT_BASE_URL}
|
|
COHERE_API_KEY: ${COHERE_API_KEY}
|
|
EMBEDDER_API_KEY: ${EMBEDDER_API_KEY:-AIzaSyA_}
|
|
QDRANT_HOST: qdrant
|
|
QDRANT_PORT: 6333
|
|
QDRANT_COLLECTION_NAME: ${QDRANT_COLLECTION_NAME:-mem0}
|
|
LOG_LEVEL: ${LOG_LEVEL:-INFO}
|
|
CORS_ORIGINS: ${CORS_ORIGINS:-http://localhost:3000}
|
|
DEFAULT_MODEL: ${DEFAULT_MODEL:-claude-sonnet-4}
|
|
API_KEYS: ${API_KEYS:-{}}
|
|
OLLAMA_BASE_URL: ${OLLAMA_BASE_URL:-http://host.docker.internal:11434}
|
|
EMBEDDING_MODEL: ${EMBEDDING_MODEL:-nomic-embed-text}
|
|
EMBEDDING_DIMS: ${EMBEDDING_DIMS:-2560}
|
|
expose:
|
|
- "8000"
|
|
networks:
|
|
- npm_network
|
|
- mem0_network
|
|
depends_on:
|
|
qdrant:
|
|
condition: service_healthy
|
|
# Backend startup loads spaCy (NLP extra), initializes mem0 v2, mounts MCP,
|
|
# and warms 4 workers — needs ~30-60s. start_period below keeps healthcheck
|
|
# failures from counting (and from triggering willfarrell/autoheal) during
|
|
# boot.
|
|
healthcheck:
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 5
|
|
start_period: 90s
|
|
restart: unless-stopped
|
|
volumes:
|
|
- ./backend:/app
|
|
- ./frontend:/app/frontend
|
|
command: ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--proxy-headers", "--forwarded-allow-ips", "*"]
|
|
|
|
volumes:
|
|
qdrant_data:
|
|
|
|
networks:
|
|
mem0_network:
|
|
npm_network:
|
|
external: true
|