- Python 3.13 venv in .venv
- Implements:
- Summarize every 6 user–assistant turns (~200 tokens) into a stripe
- Each new query loads 6 most relevant memories from mem0ai
- Total context = system prompt + long-term memory + stripes + compressed history + running history + latest query
- If context > 12k tokens, compress earliest ~6k tokens into ~500-token summary
- Long-term memory writes happen through the registered tool when required
pwsh python3.13 -m venv .venv .\.venv\Scripts\pip install --upgrade pip .\.venv\Scripts\pip install -r requirements.txt
Set environment variables before running:
- KIMI_API_KEY (or use provided NEXT_PUBLIC_KIMI_API_KEY)
- KIMI_BASE_URL (defaults to https://api.moonshot.cn/v1)
- MEM0_API_KEY (optional if using hosted mem0)
- PRELOADED_STATE_FILE (optional) – path to preprocessed stripes/compressed history JSON
If you exported all chats into conversations.json, preprocess them into a compact state:
pwsh .\.venv\Scripts\python ingest_conversations.py conversations.json preloaded_state.json
This streams the large JSON with ijson, replays the dialogue with lightweight summarisation/compression, and stores:
- stripes: ~200-token summaries of every 6-turn window
- compressed: previously-compressed history chunks (~500 tokens each)
- history: the most recent uncompressed messages
You can limit ingestion for testing:
pwsh .\.venv\Scripts\python ingest_conversations.py conversations.json preloaded_state.json --limit 10 --dry-run
Finally set PRELOADED_STATE_FILE=preloaded_state.json before running to hydrate the manager with stripes and history.
Baseline CLI (JSON output):
pwsh .\.venv\Scripts\python -m src.main
Rich console UI(图形化展示 token & 上下文来源):
pwsh .\.venv\Scripts\python -m src.ui_console
Type /ltm during the session to force a long-term memory write.