Quickstart
5분 이내에 동작하는 메모리 루프 완성. 도메인 정책 등록 → 대화 저장 → 관련 메모리 검색.
1. API 키 발급
대시보드 로그인 → API Keys → 생성. 키는 mg- prefix. 같은 페이지의 project_id도 함께 복사.
2. SDK 설치
pip install neoali-memgen3. 도메인 정책 등록 (프로젝트당 한 번)
memgen에게 무엇을 추출할지 알려줍니다. 이후 모든 add/extract 호출에 자동 적용. 언제든 변경 가능.
from memgen import MemgenClient
client = MemgenClient(api_key="mg-...")
client.project.update(
project_id="<project-id>",
extraction_policy="""
Extract dietary preferences and allergies.
Tag with: diet, allergy.
Skip: payment info, addresses.
""",
label_taxonomy=[
{"diet": "Dietary preference"},
{"allergy": "Allergic condition"},
],
)4. 대화 저장
client.add(
messages=[
{"role": "user", "content": "I'm a vegetarian and allergic to nuts."},
{"role": "assistant", "content": "Got it!"},
],
user_id="alice",
)5. 검색
hits = client.search(query="food restrictions", user_id="alice", top_k=5)
for h in hits:
print(h["memory"], h["score"])
# → "user is vegetarian, allergic to nuts" 0.876. 동기 추출 (memgen 전용)
저장 전에 추출 결과를 미리 보고 싶다면 extract 사용. store: true면 저장도 함께.
r = client.extract(
messages=[{"role":"user","content":"I just adopted a puppy named Mochi."}],
user_id="alice",
store=True,
)
print(r.summary) # → "User adopted a puppy named Mochi."
print(r.entities) # → ["puppy", "Mochi"]
print(r.tags) # → picked from your label_taxonomy
print(r.key_facts) # → ["adopted puppy named Mochi"]
print(r.memory_id) # → uuid (only when store=True)방금 일어난 일
memgen이 프로젝트 정책을 적용한 LLM으로 대화를 처리, JSON을
{summary, entities, tags, key_facts, importance} 레이어드 형태로 파싱, summary를 임베딩하여 모두 저장했습니다. 이후 search 호출이 이 메모리를 의미 검색으로 찾을 수 있습니다.다음 단계
- 개념 — 스코핑, 레이어드 추출, 프로젝트 정책
- 레시피 — AI 튜터, 고객 지원, 회의록
- SDK 전체 레퍼런스 — 모든 메서드와 시그니처