evrmem 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
evrmem-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pink
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ recursive-include src/qmd *.py
evrmem-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,431 @@
1
+ Metadata-Version: 2.4
2
+ Name: evrmem
3
+ Version: 0.0.1
4
+ Summary: QMD - 本地化 AI 向量记忆系统
5
+ Author: Pink
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/zhzgao/evrmem
8
+ Project-URL: Repository, https://github.com/zhzgao/evrmem
9
+ Project-URL: Documentation, https://zhzgao.github.io/evrmem
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: chromadb>=0.4.0
22
+ Requires-Dist: sentence-transformers>=2.2.0
23
+ Requires-Dist: pyyaml>=6.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: black>=24.0.0; extra == "dev"
26
+ Requires-Dist: isort>=5.12.0; extra == "dev"
27
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
28
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
29
+
30
+ # evrmem
31
+
32
+ > QMD - 本地化 AI 向量记忆系统 / Fully Local AI Vector Memory System
33
+
34
+ [![GitHub stars](https://img.shields.io/github/stars/zhzgao/evrmem?style=social)](https://github.com/zhzgao/evrmem/stargazers)
35
+ [![GitHub forks](https://img.shields.io/github/forks/zhzgao/evrmem?style=social)](https://github.com/zhzgao/evrmem/network/members)
36
+ [![PyPI version](https://img.shields.io/pypi/v/evrmem?color=blue)](https://pypi.org/project/evrmem/)
37
+ [![Python](https://img.shields.io/badge/python-3.9+-green.svg)](https://www.python.org/)
38
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
39
+ [![GitHub Actions Status](https://img.shields.io/github/actions/workflow/status/zhzgao/evrmem/deploy-pages.yml)](https://github.com/zhzgao/evrmem/actions)
40
+ [![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://zhzgao.github.io/evrmem)
41
+ [![Offline](https://img.shields.io/badge/100%25-Offline-green)](https://github.com/zhzgao/evrmem)
42
+ [![Chinese](https://img.shields.io/badge/中文-优化-orange)](https://github.com/zhzgao/evrmem)
43
+
44
+ ---
45
+
46
+ 📖 **在线文档**: https://zhzgao.github.io/evrmem
47
+
48
+ ---
49
+
50
+ ## English
51
+
52
+ ### What is evrmem?
53
+
54
+ evrmem (pronounced "e-vee-are-mem") is a **fully local AI vector memory system** designed for developers and AI agents. It stores, retrieves, and reasons over personal knowledge using semantic vector search — no cloud, no API keys, 100% offline.
55
+
56
+ Built on [ChromaDB](https://www.trychroma.com/) + [text2vec-base-chinese](https://huggingface.co/shibing624/text2vec-base-chinese), evrmem is optimized for **Chinese semantic understanding** and works entirely offline after initial model setup.
57
+
58
+ ### Features
59
+
60
+ - **Semantic Search** — Natural language queries with Chinese-optimized embeddings
61
+ - **Structured Query** — Filter by project, date, tags, or type
62
+ - **RAG Retrieval** — Generate context-augmented prompts for LLMs
63
+ - **100% Offline** — Works without internet after model is cached
64
+ - **Single Command CLI** — `evrmem add / search / rag / query / stats`
65
+ - **Python API** — Embed in any Python project
66
+
67
+ ### Quick Start
68
+
69
+ ```bash
70
+ # Install (from source)
71
+ pip install -e .
72
+
73
+ # Add a memory
74
+ evrmem add "React StrictMode causes Form.useForm warning" --project mes-demo --tags react,antd
75
+
76
+ # Search memories
77
+ evrmem search "React form warning fix"
78
+
79
+ # RAG: generate LLM prompt with context
80
+ evrmem rag "how to fix the form warning" --prompt
81
+
82
+ # View stats
83
+ evrmem stats
84
+
85
+ # Structured query
86
+ evrmem query --project mes-demo
87
+ ```
88
+
89
+ ### Installation
90
+
91
+ #### Option A: pip install (recommended when published)
92
+
93
+ ```bash
94
+ pip install evrmem
95
+ ```
96
+
97
+ #### Option B: Install from source
98
+
99
+ ```bash
100
+ git clone https://github.com/pink/evrmem.git
101
+ cd evrmem
102
+ pip install -e .
103
+ ```
104
+
105
+ #### Dependencies
106
+
107
+ - Python 3.9+
108
+ - `chromadb` — Vector database
109
+ - `sentence-transformers` — Embedding model
110
+ - `pyyaml` — Config file support
111
+
112
+ Embedding model (`shibing624/text2vec-base-chinese`, ~400MB) is downloaded automatically on first run.
113
+
114
+ ### Configuration
115
+
116
+ Config file `config.yaml` (in project root or `~/.evrmem/config.yaml`):
117
+
118
+ ```yaml
119
+ vector_db:
120
+ persist_directory: "~/.evrmem/data/qmd_memory"
121
+
122
+ embedding:
123
+ model_name: "shibing624/text2vec-base-chinese" # HuggingFace model
124
+ cache_folder: "~/.evrmem/models" # Local model cache
125
+ device: "cpu" # or "cuda"
126
+
127
+ rag:
128
+ top_k: 5
129
+ min_similarity: 0.5
130
+
131
+ logging:
132
+ level: "WARNING"
133
+ ```
134
+
135
+ Environment variables override config file (highest priority):
136
+
137
+ | Variable | Config Key | Description |
138
+ |----------|-----------|-------------|
139
+ | `EVREM_MODEL_NAME` | `embedding.model_name` | HuggingFace model name |
140
+ | `EVREM_LOCAL_MODEL` | `embedding.local_path` | Local model path (highest priority) |
141
+ | `EVREM_DEVICE` | `embedding.device` | `cpu` or `cuda` |
142
+ | `EVREM_DATA_DIR` | `vector_db.persist_directory` | Data directory |
143
+ | `EVREM_TOP_K` | `rag.top_k` | Default retrieval count |
144
+ | `EVREM_LOG_LEVEL` | `logging.level` | `DEBUG`, `INFO`, `WARNING`, `ERROR` |
145
+
146
+ ### CLI Reference
147
+
148
+ ```bash
149
+ # Add memory
150
+ evrmem add "content here" [-p project] [-t tags] [-d date] [-f file]
151
+
152
+ # Semantic search
153
+ evrmem search "query" [-k top_k] [-s min_similarity] [-v]
154
+ evrmem search # Interactive mode
155
+
156
+ # RAG retrieval
157
+ evrmem rag "query" [-k top_k] [-s min_similarity] [-p] # -p = generate full prompt
158
+ evrmem rag # Interactive mode
159
+
160
+ # Structured query
161
+ evrmem query [--project name] [--date YYYY-MM-DD] [--tag tag] [--type type]
162
+ evrmem query --list-projects
163
+ evrmem query --list-tags
164
+
165
+ # Stats & init
166
+ evrmem stats
167
+ evrmem init
168
+
169
+ # Help & version
170
+ evrmem --help
171
+ evrmem -v
172
+ ```
173
+
174
+ ### Python API
175
+
176
+ ```python
177
+ from qmd.core.vector_db import vector_db
178
+ from qmd.core.embedding import get_embedding_model
179
+
180
+ # Add
181
+ memory_id = vector_db.add_memory(
182
+ "React StrictMode causes Form.useForm warning",
183
+ metadata={"project": "mes-demo", "tags": "react,antd", "date": "2026-03-27"}
184
+ )
185
+
186
+ # Semantic search
187
+ results = vector_db.search("react antd form warning", top_k=5)
188
+
189
+ # Metadata query
190
+ results = vector_db.query_by_metadata({"project": "mes-demo"})
191
+
192
+ # Get embedding model directly
193
+ emb = get_embedding_model()
194
+ vec = emb.encode("hello world")
195
+ print(f"Dimension: {emb.dimension}") # 768
196
+ ```
197
+
198
+ ### Architecture
199
+
200
+ ```
201
+ User Input / CLI
202
+
203
+
204
+ ┌──────────────┐
205
+ │ qmd.cli │ ← argparse-based unified CLI
206
+ └──────┬───────┘
207
+
208
+
209
+ ┌──────────────┐ ┌────────────────────────────┐
210
+ │ VectorDB │────▶│ ChromaDB (PersistentClient) │
211
+ │ (singleton) │ └────────────────────────────┘
212
+ └──────┬───────┘
213
+ │ embed()
214
+
215
+ ┌──────────────────────────────────────────────────┐
216
+ │ EmbeddingModel (lazy-loaded) │
217
+ │ ├─ SentenceTransformer (text2vec-base-chinese) │
218
+ │ ├─ _resolve_local_model() [offline support] │
219
+ │ └─ local_files_only=True [no network calls] │
220
+ └──────────────────────────────────────────────────┘
221
+ ```
222
+
223
+ ### License
224
+
225
+ MIT — see [LICENSE](LICENSE).
226
+
227
+ ---
228
+
229
+ ## 中文
230
+
231
+ ### 什么是 evrmem?
232
+
233
+ evrmem 是一个**完全本地化的 AI 向量记忆系统**,专为开发者和 AI 智能体设计。通过语义向量搜索存储、检索和推理个人知识——无需云服务、无需 API Key、100% 离线运行。
234
+
235
+ 基于 [ChromaDB](https://www.trychroma.com/) + [text2vec-base-chinese](https://huggingface.co/shibing624/text2vec-base-chinese) 构建,针对**中文语义理解**深度优化,首次配置后完全离线工作。
236
+
237
+ ### 特性
238
+
239
+ - **语义搜索** — 自然语言查询,中文语义优先
240
+ - **结构化查询** — 按项目、日期、标签等维度筛选
241
+ - **RAG 增强** — 生成带上下文的 LLM 提示词
242
+ - **100% 离线** — 模型缓存后无需网络
243
+ - **单命令 CLI** — `evrmem add / search / rag / query / stats`
244
+ - **Python API** — 嵌入任意 Python 项目
245
+
246
+ ### 快速开始
247
+
248
+ ```bash
249
+ # 从源码安装
250
+ pip install -e .
251
+
252
+ # 添加记忆
253
+ evrmem add "React StrictMode 导致 Form.useForm 警告" --project mes-demo --tags react,antd
254
+
255
+ # 语义搜索
256
+ evrmem search "React 表单警告修复"
257
+
258
+ # RAG:生成带上下文的 LLM 提示词
259
+ evrmem rag "如何修复表单警告" --prompt
260
+
261
+ # 查看统计
262
+ evrmem stats
263
+
264
+ # 结构化查询
265
+ evrmem query --project mes-demo
266
+ ```
267
+
268
+ ### 安装
269
+
270
+ #### 方式 A:pip 安装(发布后推荐)
271
+
272
+ ```bash
273
+ pip install evrmem
274
+ ```
275
+
276
+ #### 方式 B:从源码安装
277
+
278
+ ```bash
279
+ git clone https://github.com/pink/evrmem.git
280
+ cd evrmem
281
+ pip install -e .
282
+ ```
283
+
284
+ #### 依赖
285
+
286
+ - Python 3.9+
287
+ - `chromadb` — 向量数据库
288
+ - `sentence-transformers` — Embedding 模型
289
+ - `pyyaml` — 配置文件支持
290
+
291
+ Embedding 模型(`shibing624/text2vec-base-chinese`,约 400MB)首次运行自动下载。
292
+
293
+ ### 配置
294
+
295
+ 配置文件 `config.yaml`(项目根目录或 `~/.evrmem/config.yaml`):
296
+
297
+ ```yaml
298
+ vector_db:
299
+ persist_directory: "~/.evrmem/data/qmd_memory"
300
+
301
+ embedding:
302
+ model_name: "shibing624/text2vec-base-chinese" # HuggingFace 模型名
303
+ cache_folder: "~/.evrmem/models" # 本地模型缓存目录
304
+ device: "cpu" # 或 "cuda"
305
+
306
+ rag:
307
+ top_k: 5
308
+ min_similarity: 0.5
309
+
310
+ logging:
311
+ level: "WARNING"
312
+ ```
313
+
314
+ 环境变量优先级最高(覆盖配置文件):
315
+
316
+ | 变量 | 配置项 | 说明 |
317
+ |------|--------|------|
318
+ | `EVREM_MODEL_NAME` | `embedding.model_name` | HuggingFace 模型名 |
319
+ | `EVREM_LOCAL_MODEL` | `embedding.local_path` | 本地模型路径(优先级最高) |
320
+ | `EVREM_DEVICE` | `embedding.device` | `cpu` 或 `cuda` |
321
+ | `EVREM_DATA_DIR` | `vector_db.persist_directory` | 数据目录 |
322
+ | `EVREM_TOP_K` | `rag.top_k` | 默认检索条数 |
323
+ | `EVREM_LOG_LEVEL` | `logging.level` | `DEBUG`、`INFO`、`WARNING`、`ERROR` |
324
+
325
+ ### CLI 命令参考
326
+
327
+ ```bash
328
+ # 添加记忆
329
+ evrmem add "记忆内容" [-p 项目名] [-t 标签] [-d 日期] [-f 文件路径]
330
+
331
+ # 语义搜索
332
+ evrmem search "查询内容" [-k 返回条数] [-s 最小相似度] [-v 详细输出]
333
+ evrmem search # 交互模式
334
+
335
+ # RAG 检索
336
+ evrmem rag "查询内容" [-k 条数] [-s 相似度] [-p 生成完整提示词]
337
+ evrmem rag # 交互模式
338
+
339
+ # 结构化查询
340
+ evrmem query [--project 项目名] [--date YYYY-MM-DD] [--tag 标签] [--type 类型]
341
+ evrmem query --list-projects # 列出所有项目
342
+ evrmem query --list-tags # 列出所有标签
343
+
344
+ # 统计与初始化
345
+ evrmem stats # 系统状态
346
+ evrmem init # 初始化/查看状态
347
+
348
+ # 帮助与版本
349
+ evrmem --help
350
+ evrmem -v
351
+ ```
352
+
353
+ ### Python API
354
+
355
+ ```python
356
+ from qmd.core.vector_db import vector_db
357
+ from qmd.core.embedding import get_embedding_model
358
+
359
+ # 添加记忆
360
+ memory_id = vector_db.add_memory(
361
+ "React StrictMode 导致 Form.useForm 警告",
362
+ metadata={"project": "mes-demo", "tags": "react,antd", "date": "2026-03-27"}
363
+ )
364
+
365
+ # 语义搜索
366
+ results = vector_db.search("react antd form warning", top_k=5)
367
+
368
+ # 按元数据查询
369
+ results = vector_db.query_by_metadata({"project": "mes-demo"})
370
+
371
+ # 直接使用 Embedding 模型
372
+ emb = get_embedding_model()
373
+ vec = emb.encode("你好世界")
374
+ print(f"向量维度: {emb.dimension}") # 768
375
+ ```
376
+
377
+ ### 技术架构
378
+
379
+ ```
380
+ 用户输入 / CLI 命令
381
+
382
+
383
+ ┌──────────────┐
384
+ │ qmd.cli │ ← 基于 argparse 的统一 CLI 入口
385
+ └──────┬───────┘
386
+
387
+
388
+ ┌──────────────┐ ┌────────────────────────────┐
389
+ │ VectorDB │────▶│ ChromaDB (PersistentClient) │
390
+ │ (单例模式) │ └────────────────────────────┘
391
+ └──────┬───────┘
392
+ │ embed()
393
+
394
+ ┌──────────────────────────────────────────────────┐
395
+ │ EmbeddingModel(延迟加载) │
396
+ │ ├─ SentenceTransformer (text2vec-base-chinese) │
397
+ │ ├─ _resolve_local_model() [离线路径解析] │
398
+ │ └─ local_files_only=True [零网络请求] │
399
+ └──────────────────────────────────────────────────┘
400
+ ```
401
+
402
+ ### 项目结构
403
+
404
+ ```
405
+ evrmem/
406
+ ├── src/qmd/ # 源码包
407
+ │ ├── __init__.py
408
+ │ ├── __main__.py # python -m qmd 入口
409
+ │ ├── cli.py # CLI 主逻辑
410
+ │ ├── core/
411
+ │ │ ├── config.py # 配置加载器
412
+ │ │ ├── embedding.py # Embedding 模型封装
413
+ │ │ └── vector_db.py # ChromaDB 封装
414
+ │ └── utils/
415
+ │ └── console.py # 跨平台控制台编码
416
+ ├── docs/ # 开发文档
417
+ │ ├── index.md # 文档导航
418
+ │ └── DEVELOPMENT.md # 开发指南
419
+ ├── config.yaml # 配置文件
420
+ ├── pyproject.toml # pip 包配置
421
+ ├── LICENSE # MIT 协议
422
+ ├── README.md # 本文档(中英双语)
423
+ ├── CONTRIBUTING.md # 贡献指南
424
+ ├── CHANGELOG.md # 更新日志
425
+ ├── evrmem.bat # Windows 快捷命令
426
+ └── evrmem.sh # Unix 快捷命令
427
+ ```
428
+
429
+ ### 协议
430
+
431
+ MIT — 详见 [LICENSE](LICENSE)。