{"id":48707989,"url":"https://github.com/fajknli/palacelite","last_synced_at":"2026-04-18T09:01:27.189Z","repository":{"id":350653279,"uuid":"1207740703","full_name":"fajknli/palacelite","owner":"fajknli","description":"Rooted. Reflecting.","archived":false,"fork":false,"pushed_at":"2026-04-16T08:30:48.000Z","size":185,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-17T08:02:56.500Z","etag":null,"topics":["ai","ai-memory","ai-tools","llama-cpp","local-llm","memgpt","memory","memory-palace","offline-ai","open-source","retrieval-augmented-generation","sqlite-vec"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fajknli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-11T10:37:59.000Z","updated_at":"2026-04-16T08:30:52.000Z","dependencies_parsed_at":"2026-04-18T09:01:04.615Z","dependency_job_id":null,"html_url":"https://github.com/fajknli/palacelite","commit_stats":null,"previous_names":["fajknli/palacelite"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/fajknli/palacelite","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajknli%2Fpalacelite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajknli%2Fpalacelite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajknli%2Fpalacelite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajknli%2Fpalacelite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fajknli","download_url":"https://codeload.github.com/fajknli/palacelite/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fajknli%2Fpalacelite/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31962889,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ai-memory","ai-tools","llama-cpp","local-llm","memgpt","memory","memory-palace","offline-ai","open-source","retrieval-augmented-generation","sqlite-vec"],"created_at":"2026-04-11T12:30:07.665Z","updated_at":"2026-04-18T09:01:27.147Z","avatar_url":"https://github.com/fajknli.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PalaceLite\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)\n[![PyPI version](https://badge.fury.io/py/palacelite.svg)](https://pypi.org/project/palacelite/)\n\n轻量级 AI 记忆系统，灵感来自 MemPalace。默认离线运行，数据完全本地化。\n\n## 安装\n\n```bash\npip install palacelite\n```\n\n首次使用需下载嵌入模型（约 100MB），添加 `--online` 参数即可自动下载，之后可永久离线运行：\n\n```bash\npalacelite chat -m /path/to/model.gguf --online\n```\n\n## 核心概念\n\n采用三层结构组织记忆：\n\n- **Wing**：项目或人\n- **Room**：具体话题\n- **Drawer**：记忆条目\n\n每条记忆存储原文和向量，支持混合检索（向量相似度 + 关键词匹配 + 时间衰减 + 重要性加权）。\n\n## 快速开始\n\n### CLI 命令\n\n```bash\n# 添加记忆\npalacelite add -w default -r chat -c \"用户喜欢 PostgreSQL\"\n\n# 搜索记忆\npalacelite search -q \"数据库\"\n\n# 带记忆对话\npalacelite chat -m /path/to/model.gguf -w default -r chat\n\n# 列出活跃记忆\npalacelite list\n\n# 统计信息\npalacelite stats\n\n# 列出所有 Wing\npalacelite wings\n\n# 列出指定 Wing 下的 Room\npalacelite rooms default\n```\n\n### Python API\n\n```python\nfrom palacelite import PalaceLite\n\np = PalaceLite()  # 默认离线，offline=False 可联网下载模型\n\n# 添加记忆\np.add_memory(\"用户喜欢 PostgreSQL\", \"default\", \"chat\")\n\n# 搜索\nresults = p.search(\"数据库\")\n\n# 构建 LLM 上下文\ncontext = p.build_context(\"数据库选型\")\n```\n\n### 对话模式\n\n```bash\n# 首次使用（下载嵌入模型）\npalacelite chat -m /path/to/model.gguf --online\n\n# 日常使用\npalacelite chat -m /path/to/model.gguf\n\n# 指定 GPU 层数\npalacelite chat -m /path/to/model.gguf -g 30\n\n# 使用提炼模型压缩记忆（推荐 3B 小模型，如 Qwen2.5-3B-Instruct）\npalacelite chat -m /path/to/model.gguf --distiller-model /path/to/small.gguf\n\n# 手动指定 prompt 模板（支持 qwen/gemma/llama/mistral）\npalacelite chat -m /path/to/model.gguf --prompt-template qwen\n```\n\n## 对话内命令\n\n| 命令 | 说明 |\n|------|------|\n| `/help` | 显示帮助 |\n| `/mem \u003c关键词\u003e` | 搜索记忆 |\n| `/add \u003c内容\u003e` | 手动添加记忆 |\n| `/list [数量]` | 列出最近记忆 |\n| `/stats` | 显示统计信息 |\n| `/clear` | 清屏 |\n| `/quit` | 退出对话 |\n\n## 记忆维护\n\n### 归档旧记忆\n\n```bash\n# 归档超过 90 天且重要性低于 2 的记忆\npalacelite archive-old --days 90 --importance 2\n\n# 列出已归档记忆\npalacelite list-archived\n\n# 导出归档记忆到 JSON\npalacelite export-archived\n\n# 永久删除归档记忆\npalacelite delete-archived\n```\n\n### 数据清洗与重建\n\n```bash\n# 清洗导出数据（用于微调）\npython scripts/clean_memories.py ~/backup.json ~/cleaned.json\n\n# 更换嵌入模型后重建向量库\npython scripts/rebuild_embeddings.py\n```\n\n## 命令速查\n\n| 命令 | 说明 |\n|------|------|\n| `add -w \u003cwing\u003e -r \u003croom\u003e -c \u003c内容\u003e` | 添加记忆 |\n| `search -q \u003c关键词\u003e` | 搜索记忆 |\n| `chat -m \u003c模型路径\u003e` | 启动对话 |\n| `list [-w wing] [-r room]` | 列出活跃记忆 |\n| `stats` | 显示统计信息 |\n| `wings` | 列出所有 Wing |\n| `rooms \u003cwing\u003e` | 列出 Wing 下的 Room |\n| `archive-old [--days 90] [--importance 2]` | 批量归档 |\n| `list-archived` | 列出已归档记忆 |\n| `export-archived [-o 路径]` | 导出归档 |\n| `delete-archived` | 删除归档 |\n\n## 配置\n\n| 环境变量 | 默认值 | 说明 |\n|----------|--------|------|\n| `PALACE_MODEL_PATH` | - | GGUF 模型文件路径 |\n| `PALACE_MODEL_DIR` | `~/Public/ai/models` | 模型存放目录 |\n| `GPU_LAYERS` | `20` | GPU 加速层数 |\n\n工作目录默认为 `~/.palacelite`，可通过 `PalaceLite(workspace=\"/path\")` 自定义。\n\n## 架构\n\n当前版本 (0.5.1) 已完成：\n\n- SQLite-vec 向量存储，无需外部向量数据库\n- 异步记忆提炼（Distiller），支持技术参数原样保留\n- 混合检索：向量相似度 + 关键词匹配 + 时间衰减 + 重要性加权\n- 关系图谱 Schema（relations、patrol_queue），为后续版本做准备\n- 记忆归档与导出\n- 对话内手动添加记忆（`/add`）\n- 自动 prompt 模板检测\n\n## 许可证\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffajknli%2Fpalacelite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffajknli%2Fpalacelite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffajknli%2Fpalacelite/lists"}