마이그레이션 가이드

memgen의 surface는 의도적으로 mem0와 유사합니다. 대부분 앱은 3줄 변경으로 끝.

mem0에서

1. 클라이언트 교체

# before
from mem0 import MemoryClient
client = MemoryClient(api_key="m0-...")

# after
from memgen import MemgenClient
client = MemgenClient(api_key="mg-...", base_url="https://memgen.neoali.com")

2. 메서드 호출 — 거의 동일

client.add(messages=[...], user_id="alice")
client.search(query="...", user_id="alice", top_k=5)
client.get(memory_id)
client.update(memory_id, memory="...")
client.delete(memory_id)
client.delete_all(user_id="alice")

3. 프로젝트 설정 — 명칭이 다름

mem0는 custom_instructions + custom_categories. memgen은 extraction_policy + label_taxonomy. 같은 개념, 다른 이름.

# mem0
client.project.update(custom_instructions="...", custom_categories=[...])

# memgen
client.project.update(
    project_id="<id>",
    extraction_policy="...",
    label_taxonomy=[...],
)

왜 이름을 바꿨나요?

설명적 용어("policy" = 가이드라인; "taxonomy" = 라벨 세트)를 채택하고 상표 인접 식별자를 피했습니다. 기능적으로 동등.

memgen 전용 추가 기능

  • extract(messages, store=False) — 레이어드 {summary, entities, tags, key_facts, importance} 형태를 반환하는 동기 추출. 검사·모더레이션에 유용.
  • 레이어드 메타데이터 — 모든 메모리에 flat 문자열과 별도로 구조화된 core 블록. memory.memory를 읽던 옛 mem0 코드 그대로 작동.
  • Engine 직접 API (/v1/engine/*) — raw embedding / consolidate / fork-delete 연산.
  • Self-hosting — 자체 GPU에서 풀 Docker Compose 스택. mem0는 현재 SaaS only.

데이터 내보내기 / 가져오기

mem0의 POST /memories/export로 내보낸 뒤, memgen에 일괄 import:

import json
mem0_export = json.load(open("mem0-export.json"))

for m in mem0_export["memories"]:
    client.add(
        messages=[{"role": "user", "content": m["memory"]}],
        user_id=m.get("user_id"),
        metadata=m.get("metadata") or {},
    )

Self-hosting

Docker Compose로 자체 인프라에서 memgen 실행. 스택에 Postgres, Redis, Qdrant, RabbitMQ, FastAPI 백엔드, Next.js 프런트엔드, memory-engine GPU 서비스 포함.

git clone https://github.com/neoali/memgen
cd memgen
cp .env.example .env
docker compose up -d

그다음 SDK를 로컬 인스턴스로 가리키기:

client = MemgenClient(api_key="mg-...", base_url="http://localhost:18000")