Skip to main content

tanstack-ai-memory-in-memory

Use when wiring inMemory() from @tanstack/ai-memory/in-memory — explains setup, options (embedder, extract, topK/minScore), when to pick it (dev/tests/single-process demos), and what NOT to use it for (multi-process or persistent).

소스 정보

저장소
TanStack/ai
최근 소스 활동
2026년 9월 9일 06:08
감지된 SKILL.md 언어
영어
스타
3,199
포크
366

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
tanstack-ai-memory-in-memory
description
Use when wiring inMemory() from @tanstack/ai-memory/in-memory — explains setup, options (embedder, extract, topK/minScore), when to pick it (dev/tests/single-process demos), and what NOT to use it for (multi-process or persistent).
# In-Memory Memory Adapter Zero-dependency `recall`/`save` adapter backed by a `Map`. Records vanish on process restart. ## When to use it - Local development. - Vitest / Playwright tests. - Single-process demos where users don't need persistence. ## When NOT to use it - Production multi-process deployments — every worker has its own `Map`; users get inconsistent memory. - Anything that needs survival across restarts. For production, use `redis()` (see the `tanstack-ai-memory-redis` skill). ## Setup ```ts import { memoryMiddleware } from '@tanstack/ai-memory' import { inMemory } from '@tanstack/ai-memory/in-memory' const memory = inMemory() // A static scope is fine for dev/tests; derive it from the session in real apps. memoryMiddleware({ adapter: memory, scope: { threadId: 'demo-thread', userId: 'alice' }, }) ``` ## Options `inMemory(options?)` accepts: - `topK` (default 6), `minScore` (default 0.15), `kinds` — recall tuning. - `embedder: { embed(text): Promise<number[]> }` — enable semantic scoring (both `recall` and `save` embed through it). - `extract(turn, scope)` — return derived facts to persist alongside the raw turn (e.g. call an LLM to pull out preferences). Without it, `save` stores the raw user/assistant messages and `recall` scores them lexically + by recency. - `render(hits)` — replace the built-in prompt renderer. ## Capacity The adapter scans every record in a scope per `recall`. Fine up to ~100k records; beyond that, switch to Redis.
GitHub에서 보기