MemoryOS 0.1.12__py3-none-any.whl → 0.2.0__py3-none-any.whl
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.
Potentially problematic release.
This version of MemoryOS might be problematic. Click here for more details.
- {memoryos-0.1.12.dist-info → memoryos-0.2.0.dist-info}/METADATA +51 -31
- {memoryos-0.1.12.dist-info → memoryos-0.2.0.dist-info}/RECORD +32 -21
- memos/__init__.py +1 -1
- memos/configs/internet_retriever.py +81 -0
- memos/configs/llm.py +1 -0
- memos/configs/mem_os.py +4 -0
- memos/configs/mem_reader.py +4 -0
- memos/configs/memory.py +11 -1
- memos/graph_dbs/item.py +46 -0
- memos/graph_dbs/neo4j.py +72 -5
- memos/llms/openai.py +1 -0
- memos/mem_os/main.py +491 -0
- memos/mem_reader/simple_struct.py +11 -6
- memos/mem_user/user_manager.py +10 -0
- memos/memories/textual/item.py +3 -1
- memos/memories/textual/tree.py +39 -3
- memos/memories/textual/tree_text_memory/organize/conflict.py +196 -0
- memos/memories/textual/tree_text_memory/organize/manager.py +49 -8
- memos/memories/textual/tree_text_memory/organize/redundancy.py +212 -0
- memos/memories/textual/tree_text_memory/organize/relation_reason_detector.py +235 -0
- memos/memories/textual/tree_text_memory/organize/reorganizer.py +584 -0
- memos/memories/textual/tree_text_memory/retrieve/internet_retriever.py +263 -0
- memos/memories/textual/tree_text_memory/retrieve/internet_retriever_factory.py +89 -0
- memos/memories/textual/tree_text_memory/retrieve/reasoner.py +1 -4
- memos/memories/textual/tree_text_memory/retrieve/searcher.py +46 -4
- memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py +3 -3
- memos/memories/textual/tree_text_memory/retrieve/xinyusearch.py +335 -0
- memos/templates/mem_reader_prompts.py +42 -15
- memos/templates/mos_prompts.py +63 -0
- memos/templates/tree_reorganize_prompts.py +168 -0
- {memoryos-0.1.12.dist-info → memoryos-0.2.0.dist-info}/LICENSE +0 -0
- {memoryos-0.1.12.dist-info → memoryos-0.2.0.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: MemoryOS
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Intelligence Begins with Memory
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: memory,llm,language model,memoryOS,agent
|
|
@@ -22,6 +22,7 @@ Requires-Dist: ollama (>=0.4.8,<0.5.0)
|
|
|
22
22
|
Requires-Dist: openai (>=1.77.0,<2.0.0)
|
|
23
23
|
Requires-Dist: qdrant-client (>=1.14.2,<2.0.0)
|
|
24
24
|
Requires-Dist: redis (>=6.2.0,<7.0.0)
|
|
25
|
+
Requires-Dist: schedule (>=1.2.2,<2.0.0)
|
|
25
26
|
Requires-Dist: sentence-transformers (>=4.1.0,<5.0.0)
|
|
26
27
|
Requires-Dist: sqlalchemy (>=2.0.41,<3.0.0)
|
|
27
28
|
Requires-Dist: tenacity (>=9.1.2,<10.0.0)
|
|
@@ -31,13 +32,11 @@ Description-Content-Type: text/markdown
|
|
|
31
32
|
|
|
32
33
|
<div align="center">
|
|
33
34
|
<a href="https://memos.openmem.net/">
|
|
34
|
-
<img src="
|
|
35
|
+
<img src="https://statics.memtensor.com.cn/memos/memos-banner.gif" alt="MemOS Banner">
|
|
35
36
|
</a>
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
38
|
<h1 align="center">
|
|
40
|
-
<img src="
|
|
39
|
+
<img src="https://statics.memtensor.com.cn/logo/memos_color_m.png" alt="MemOS Logo" width="50"/> MemOS 1.0: 星河 (Stellar) <img src="https://img.shields.io/badge/status-Preview-blue" alt="Preview Badge"/>
|
|
41
40
|
</h1>
|
|
42
41
|
|
|
43
42
|
<p>
|
|
@@ -50,11 +49,11 @@ Description-Content-Type: text/markdown
|
|
|
50
49
|
<a href="https://pypi.org/project/MemoryOS">
|
|
51
50
|
<img src="https://img.shields.io/pypi/pyversions/MemoryOS.svg" alt="Supported Python versions">
|
|
52
51
|
</a>
|
|
53
|
-
<a href="https://memos.openmem.net/
|
|
52
|
+
<a href="https://memos-docs.openmem.net/home/overview/">
|
|
54
53
|
<img src="https://img.shields.io/badge/Documentation-view-blue.svg" alt="Documentation">
|
|
55
54
|
</a>
|
|
56
|
-
<a href="https://arxiv.org/abs/
|
|
57
|
-
<img src="https://img.shields.io/badge/arXiv-
|
|
55
|
+
<a href="https://arxiv.org/abs/2507.03724">
|
|
56
|
+
<img src="https://img.shields.io/badge/arXiv-2507.03724-b31b1b.svg" alt="ArXiv Paper">
|
|
58
57
|
</a>
|
|
59
58
|
<a href="https://github.com/MemTensor/MemOS/discussions">
|
|
60
59
|
<img src="https://img.shields.io/badge/GitHub-Discussions-181717.svg?logo=github" alt="GitHub Discussions">
|
|
@@ -62,7 +61,7 @@ Description-Content-Type: text/markdown
|
|
|
62
61
|
<a href="https://discord.gg/Txbx3gebZR">
|
|
63
62
|
<img src="https://img.shields.io/badge/Discord-join%20chat-7289DA.svg?logo=discord" alt="Discord">
|
|
64
63
|
</a>
|
|
65
|
-
<a href="
|
|
64
|
+
<a href="https://statics.memtensor.com.cn/memos/qr-code.png">
|
|
66
65
|
<img src="https://img.shields.io/badge/WeChat-Group-07C160.svg?logo=wechat" alt="WeChat Group">
|
|
67
66
|
</a>
|
|
68
67
|
<a href="https://opensource.org/license/apache-2-0/">
|
|
@@ -73,17 +72,14 @@ Description-Content-Type: text/markdown
|
|
|
73
72
|
|
|
74
73
|
---
|
|
75
74
|
|
|
76
|
-
|
|
77
|
-
<img src="docs/assets/SOTA_Score.jpg" alt="SOTA SCORE">
|
|
78
|
-
</a>
|
|
79
|
-
|
|
75
|
+
<img src="https://statics.memtensor.com.cn/memos/sota_score.jpg" alt="SOTA SCORE">
|
|
80
76
|
|
|
81
77
|
**MemOS** is an operating system for Large Language Models (LLMs) that enhances them with long-term memory capabilities. It allows LLMs to store, retrieve, and manage information, enabling more context-aware, consistent, and personalized interactions.
|
|
82
78
|
|
|
83
|
-
- **Website**:
|
|
84
|
-
- **Documentation**:
|
|
85
|
-
- **API Reference**:
|
|
86
|
-
- **Source Code**:
|
|
79
|
+
- **Website**: https://memos.openmem.net/
|
|
80
|
+
- **Documentation**: https://memos-docs.openmem.net/home/overview/
|
|
81
|
+
- **API Reference**: https://memos-docs.openmem.net/docs/api/info/
|
|
82
|
+
- **Source Code**: https://github.com/MemTensor/MemOS
|
|
87
83
|
|
|
88
84
|
## 📈 Performance Benchmark
|
|
89
85
|
|
|
@@ -97,19 +93,12 @@ MemOS demonstrates significant improvements over baseline memory solutions in mu
|
|
|
97
93
|
|
|
98
94
|
> 💡 **Temporal reasoning accuracy improved by 159% compared to the OpenAI baseline.**
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
96
|
### Details of End-to-End Evaluation on LOCOMO
|
|
103
97
|
|
|
104
98
|
> [!NOTE]
|
|
105
99
|
> Comparison of LLM Judge Scores across five major tasks in the LOCOMO benchmark. Each bar shows the mean evaluation score judged by LLMs for a given method-task pair, with standard deviation as error bars. MemOS-0630 consistently outperforms baseline methods (LangMem, Zep, OpenAI, Mem0) across all task types, especially in multi-hop and temporal reasoning scenarios.
|
|
106
100
|
|
|
107
|
-
<
|
|
108
|
-
<img src="docs/assets/score_all_end2end.jpg" alt="END2END SCORE">
|
|
109
|
-
</a>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
<img src="https://statics.memtensor.com.cn/memos/score_all_end2end.jpg" alt="END2END SCORE">
|
|
113
102
|
|
|
114
103
|
## ✨ Key Features
|
|
115
104
|
|
|
@@ -182,7 +171,11 @@ For more detailed examples, please check out the [`examples`](./examples) direct
|
|
|
182
171
|
## 📦 Installation
|
|
183
172
|
|
|
184
173
|
> [!WARNING]
|
|
185
|
-
>
|
|
174
|
+
> MemOS is compatible with Linux, Windows, and macOS.
|
|
175
|
+
>
|
|
176
|
+
> However, if you're using macOS, please note that there may be dependency issues that are difficult to resolve.
|
|
177
|
+
>
|
|
178
|
+
> For example, compatibility with macOS 13 Ventura is currently challenging.
|
|
186
179
|
|
|
187
180
|
### Install via pip
|
|
188
181
|
|
|
@@ -223,24 +216,50 @@ Join our community to ask questions, share your projects, and connect with other
|
|
|
223
216
|
- **Discord**: Join our <a href="https://discord.gg/Txbx3gebZR" target="_blank">Discord Server</a>.
|
|
224
217
|
- **WeChat**: Scan the QR code to join our WeChat group.
|
|
225
218
|
|
|
226
|
-
<img src="
|
|
219
|
+
<img src="https://statics.memtensor.com.cn/memos/qr-code.png" alt="QR Code" width="600">
|
|
227
220
|
|
|
228
221
|
## 📜 Citation
|
|
229
222
|
|
|
230
|
-
|
|
223
|
+
> [!NOTE]
|
|
224
|
+
> We publicly released the Short Version on **May 28, 2025**, making it the earliest work to propose the concept of a Memory Operating System for LLMs.
|
|
225
|
+
|
|
226
|
+
If you use MemOS in your research, we would appreciate citations to our papers.
|
|
231
227
|
|
|
232
228
|
```bibtex
|
|
233
|
-
|
|
229
|
+
|
|
230
|
+
@article{li2025memos_long,
|
|
231
|
+
title={MemOS: A Memory OS for AI System},
|
|
232
|
+
author={Li, Zhiyu and Song, Shichao and Xi, Chenyang and Wang, Hanyu and Tang, Chen and Niu, Simin and Chen, Ding and Yang, Jiawei and Li, Chunyu and Yu, Qingchen and Zhao, Jihao and Wang, Yezhaohui and Liu, Peng and Lin, Zehao and Wang, Pengyuan and Huo, Jiahao and Chen, Tianyi and Chen, Kai and Li, Kehang and Tao, Zhen and Ren, Junpeng and Lai, Huayi and Wu, Hao and Tang, Bo and Wang, Zhenren and Fan, Zhaoxin and Zhang, Ningyu and Zhang, Linfeng and Yan, Junchi and Yang, Mingchuan and Xu, Tong and Xu, Wei and Chen, Huajun and Wang, Haofeng and Yang, Hongkang and Zhang, Wentao and Xu, Zhi-Qin John and Chen, Siheng and Xiong, Feiyu},
|
|
233
|
+
journal={arXiv preprint arXiv:2507.03724},
|
|
234
|
+
year={2025},
|
|
235
|
+
url={https://arxiv.org/abs/2507.03724}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@article{li2025memos_short,
|
|
234
239
|
title={MemOS: An Operating System for Memory-Augmented Generation (MAG) in Large Language Models},
|
|
235
240
|
author={Li, Zhiyu and Song, Shichao and Wang, Hanyu and Niu, Simin and Chen, Ding and Yang, Jiawei and Xi, Chenyang and Lai, Huayi and Zhao, Jihao and Wang, Yezhaohui and others},
|
|
236
241
|
journal={arXiv preprint arXiv:2505.22101},
|
|
237
|
-
year={2025}
|
|
242
|
+
year={2025},
|
|
243
|
+
url={https://arxiv.org/abs/2505.22101}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
@article{yang2024memory3,
|
|
247
|
+
author = {Yang, Hongkang and Zehao, Lin and Wenjin, Wang and Wu, Hao and Zhiyu, Li and Tang, Bo and Wenqiang, Wei and Wang, Jinbo and Zeyun, Tang and Song, Shichao and Xi, Chenyang and Yu, Yu and Kai, Chen and Xiong, Feiyu and Tang, Linpeng and Weinan, E},
|
|
248
|
+
title = {Memory$^3$: Language Modeling with Explicit Memory},
|
|
249
|
+
journal = {Journal of Machine Learning},
|
|
250
|
+
year = {2024},
|
|
251
|
+
volume = {3},
|
|
252
|
+
number = {3},
|
|
253
|
+
pages = {300--346},
|
|
254
|
+
issn = {2790-2048},
|
|
255
|
+
doi = {https://doi.org/10.4208/jml.240708},
|
|
256
|
+
url = {https://global-sci.com/article/91443/memory3-language-modeling-with-explicit-memory}
|
|
238
257
|
}
|
|
239
258
|
```
|
|
240
259
|
|
|
241
260
|
## 🙌 Contributing
|
|
242
261
|
|
|
243
|
-
We welcome contributions from the community! Please read our [contribution guidelines](
|
|
262
|
+
We welcome contributions from the community! Please read our [contribution guidelines](https://memos-docs.openmem.net/contribution/overview) to get started.
|
|
244
263
|
|
|
245
264
|
## 📄 License
|
|
246
265
|
|
|
@@ -251,6 +270,7 @@ MemOS is licensed under the [Apache 2.0 License](./LICENSE).
|
|
|
251
270
|
Stay up to date with the latest MemOS announcements, releases, and community highlights.
|
|
252
271
|
|
|
253
272
|
- **2025-07-07** – 🎉 *MemOS 1.0 (Stellar) Preview Release*: A SOTA Memory OS for LLMs is now open-sourced.
|
|
273
|
+
- **2025-07-04** – 🎉 *MemOS Paper Released*: [MemOS: A Memory OS for AI System](https://arxiv.org/abs/2507.03724) was published on arXiv.
|
|
254
274
|
- **2025-05-28** – 🎉 *Short Paper Uploaded*: [MemOS: An Operating System for Memory-Augmented Generation (MAG) in Large Language Models](https://arxiv.org/abs/2505.22101) was published on arXiv.
|
|
255
275
|
- **2024-07-04** – 🎉 *Memory3 Model Released at WAIC 2024*: The new memory-layered architecture model was unveiled at the 2024 World Artificial Intelligence Conference.
|
|
256
276
|
- **2024-07-01** – 🎉 *Memory3 Paper Released*: [Memory3: Language Modeling with Explicit Memory](https://arxiv.org/abs/2407.01178) introduces the new approach to structured memory in LLMs.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
memos/__init__.py,sha256=
|
|
1
|
+
memos/__init__.py,sha256=9C9wxypP0Ch_j6yjvoNgmbr8spHUAsdC1hd49UswG2U,575
|
|
2
2
|
memos/api/start_api.py,sha256=vDKS3D8AEwlDAkpWxHiblzVqcQ3cvGSnnpP4Jhjm3GE,14656
|
|
3
3
|
memos/chunkers/__init__.py,sha256=7lZOTN3e9Yp5XBsDX5wnWJ3tY126cRU9GmfevzJXAtU,67
|
|
4
4
|
memos/chunkers/base.py,sha256=z0rG5vM7FGremQdSZ_3jlTGbsDtlkWAYWdtSAGqpaR4,655
|
|
@@ -9,13 +9,14 @@ memos/configs/base.py,sha256=bOOhEU6HGFTq5jne_TXn8Br72rvAfJHYvYllFUPs12A,2588
|
|
|
9
9
|
memos/configs/chunker.py,sha256=Ulci0MyhS_FkuV95l7Pr9Vei179aEFEUigwVmtmSDfI,1593
|
|
10
10
|
memos/configs/embedder.py,sha256=a7EbWB3tnqeK_pdK6-CneoKIwSqQg6sJrXuHX3J1PnI,1769
|
|
11
11
|
memos/configs/graph_db.py,sha256=h5wz2lJSdB1IVaidzWHXDfvL4_IAjrjYrmypu1QCCq4,1432
|
|
12
|
-
memos/configs/
|
|
12
|
+
memos/configs/internet_retriever.py,sha256=7x1Sp--skifHQqWvcPFiEOkda6HCCocw6HSO5H127jk,3046
|
|
13
|
+
memos/configs/llm.py,sha256=iNLGnZYbeqkLpjP4L0sGzoCnH4NH8SBUzBt6bTohxZI,2446
|
|
13
14
|
memos/configs/mem_chat.py,sha256=TjEQHRG1HpLwCBo3hrn5aVK23rykNtV6Be5p4YIg7F4,2571
|
|
14
15
|
memos/configs/mem_cube.py,sha256=AvffqpFC2WmzshouxLJbabuzt0PKLWSauQMnagP_EM0,3088
|
|
15
|
-
memos/configs/mem_os.py,sha256=
|
|
16
|
-
memos/configs/mem_reader.py,sha256=
|
|
16
|
+
memos/configs/mem_os.py,sha256=bUuyi6boIjjvYzrlFoCSqchbWF37IcA5BQi03feq7bg,2476
|
|
17
|
+
memos/configs/mem_reader.py,sha256=m5pRr3DxtmOKBFdbnCki_XgG47oKfcasJNwZGXg9gN4,2022
|
|
17
18
|
memos/configs/mem_scheduler.py,sha256=bTsBfl9GoXbjkiPDCenH8K2QY4RfAJNk-XN1UBl2W4Q,2959
|
|
18
|
-
memos/configs/memory.py,sha256=
|
|
19
|
+
memos/configs/memory.py,sha256=kAGmniEgBdHgAsZGXeUF7J-ekwU5H9HnxQp_3jhUtLQ,6976
|
|
19
20
|
memos/configs/parser.py,sha256=dy-QoevJbCnkJePKgpzR4oziOzYnS4jB6XH-YrpeMns,1145
|
|
20
21
|
memos/configs/utils.py,sha256=X9NQ6-xURsZROAdS3WT96phVfHcOHgDPOo2Yq68QoKM,242
|
|
21
22
|
memos/configs/vec_db.py,sha256=Gjhhda94pyTDjyJGe2Z6rVEqH4FtViiwq1-7QWhjarM,2335
|
|
@@ -29,14 +30,15 @@ memos/exceptions.py,sha256=UnBoZUYdwb1KoQPE-pXSLT4yOjkwxse9fx0rb_MhEzo,531
|
|
|
29
30
|
memos/graph_dbs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
31
|
memos/graph_dbs/base.py,sha256=dTCdoYNS6FZQukpmpqhh8c_NwZ9Myql41g1Im8aDR6E,6873
|
|
31
32
|
memos/graph_dbs/factory.py,sha256=9fS8w0GowWNMSupEyXyTRnivX-RJxTkxPy-tNHs15OM,732
|
|
32
|
-
memos/graph_dbs/
|
|
33
|
+
memos/graph_dbs/item.py,sha256=BfK17hA_hHu7I348jWugP_rb9GS5hpKfgqtYGGHBohk,1450
|
|
34
|
+
memos/graph_dbs/neo4j.py,sha256=bOTBvHGw_65dudqIpQep9D95qBPyx-NHfTybsNAdjiM,33672
|
|
33
35
|
memos/hello_world.py,sha256=RV1vXfK1_U_xAvSusqc-4A8wk3yr8WEQ9q88dmBxvnI,3057
|
|
34
36
|
memos/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
37
|
memos/llms/base.py,sha256=E7qlIWUi_bxRwbKw0vGG7NjHksz45D_-gcrHKT3Ak1k,438
|
|
36
38
|
memos/llms/factory.py,sha256=1JP2ZwUKN4ywaNgdZcRM6wSjahnEXqyuFiGzoxLCadY,792
|
|
37
39
|
memos/llms/hf.py,sha256=rxcR8nAvhezsIQNeOeow-xn-z2h9j1poJO2jPNcJAg8,9008
|
|
38
40
|
memos/llms/ollama.py,sha256=_nZYe0OauPWWcFFYVPSNtvyDGblrL49-EznApa-Mr5I,2565
|
|
39
|
-
memos/llms/openai.py,sha256=
|
|
41
|
+
memos/llms/openai.py,sha256=agIFI58UXz-fOEth4EBTUlQ5p6ECBg9v2gFed6OVFzw,1192
|
|
40
42
|
memos/llms/utils.py,sha256=OcbM9iSpFJpio7sTT5wvxVx-JnqjIx7eSgiRk7dt0ZI,292
|
|
41
43
|
memos/log.py,sha256=ocQi2NWlpefgxOJi9EoB0as6tXhLA4dmXuVIgZT52FE,2234
|
|
42
44
|
memos/mem_chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -49,13 +51,13 @@ memos/mem_cube/general.py,sha256=ad7Qzshf-psBuu24BX_K0NDN0KDuwliAi06TG4wyH1M,553
|
|
|
49
51
|
memos/mem_cube/utils.py,sha256=-6KiCCzy1PehbGAZY20BVcelvdiKFSu4CXMXi8qNrGU,777
|
|
50
52
|
memos/mem_os/client.py,sha256=0M-WRTlQr7fDAYtq4B8dsMR0PfmyvD-ySMhKcW3Umd0,43
|
|
51
53
|
memos/mem_os/core.py,sha256=csZQqZfbdACapcA85Ahh8vBfi0VPFGM_6yilfmln008,34836
|
|
52
|
-
memos/mem_os/main.py,sha256=
|
|
54
|
+
memos/mem_os/main.py,sha256=sGMleiO1_CG8-v3ctIMFe1hx8Jy_OohFtqqpWgRMhbw,21099
|
|
53
55
|
memos/mem_os/product.py,sha256=SFLFEleZISCeBU19b-uohFsaUNXB9tN-GGypuhDFx1I,3043
|
|
54
56
|
memos/mem_reader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
57
|
memos/mem_reader/base.py,sha256=SSuaD3J88XbHsME1Qa-EAgZ57xApPHPHppMSeeS3JZ4,957
|
|
56
58
|
memos/mem_reader/factory.py,sha256=emKnId9BhScSkqCZyLSLWntixnU3wAMIOVdsRpHldJA,766
|
|
57
59
|
memos/mem_reader/memory.py,sha256=f3fAjrs8Jf6mBZWTgzkEZle7XjDwTJHxM1L2sOb85Tg,13288
|
|
58
|
-
memos/mem_reader/simple_struct.py,sha256=
|
|
60
|
+
memos/mem_reader/simple_struct.py,sha256=SfFxtZ_YGcDh-A4Ztx4ouEBC6m0j8mLCVF2HN4oGRy8,9739
|
|
59
61
|
memos/mem_scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
60
62
|
memos/mem_scheduler/base_scheduler.py,sha256=bYxLm6nUorJGm8DCiBOJ6DG8eqCK3cCIrm3cEe2be7M,6617
|
|
61
63
|
memos/mem_scheduler/general_scheduler.py,sha256=Tp9Nh8qFVR9TklmmISSoBoeHoWTqM0P977gmb-HS6rM,12895
|
|
@@ -68,7 +70,7 @@ memos/mem_scheduler/modules/retriever.py,sha256=NJEFpX2ap4mSQZ9GYBvBr9QMD4QpgLEY
|
|
|
68
70
|
memos/mem_scheduler/modules/schemas.py,sha256=J7Rv4M932Wdm-NoOWQne9txOK7j0V9ScdsRH7klPGTI,5301
|
|
69
71
|
memos/mem_scheduler/scheduler_factory.py,sha256=pw6FKO0EuxFRipMnD22DvcjbM6pdmVfJmRjUvdTaU5E,800
|
|
70
72
|
memos/mem_scheduler/utils.py,sha256=xa2BotLf7iAQ4bVJEujPvRjuzWItOA2gP2H3BkBM5XY,582
|
|
71
|
-
memos/mem_user/user_manager.py,sha256=
|
|
73
|
+
memos/mem_user/user_manager.py,sha256=9XIt4Q2HA1fhh9dbjKRAXh-GTdT43WGYSx-IsST7jZM,15654
|
|
72
74
|
memos/memories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
73
75
|
memos/memories/activation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
74
76
|
memos/memories/activation/base.py,sha256=kiC35AOnuofgYMzLxZyVULsfOoVq03BGvi6AXtNvF-I,1151
|
|
@@ -83,35 +85,44 @@ memos/memories/parametric/lora.py,sha256=TqSI2OjmFi-XXCeM-MchSwh1sAhOwL7_JnOwSy9
|
|
|
83
85
|
memos/memories/textual/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
86
|
memos/memories/textual/base.py,sha256=3XVeuXZY3ZFzZ6zHIE3l5hx7X2PiH7orxvCwrNZ1l3U,2812
|
|
85
87
|
memos/memories/textual/general.py,sha256=7iektZA-_iR80sOlADW2EFkPT5Utbunu9hdZgT7Ocrk,11072
|
|
86
|
-
memos/memories/textual/item.py,sha256=
|
|
88
|
+
memos/memories/textual/item.py,sha256=8tSsiDztsxfyNXWB1TG2E5a4nhIQcuYMJ_BrnPl6osQ,6323
|
|
87
89
|
memos/memories/textual/naive.py,sha256=Z_gfbxI6cQGJ_raOTQic4fnpo493Xq3yEQ8qDV4xplo,6954
|
|
88
|
-
memos/memories/textual/tree.py,sha256=
|
|
90
|
+
memos/memories/textual/tree.py,sha256=xOc4yMO-tISHmndS-T3ZxGQDr3cARapiTU71PTZdJbQ,13514
|
|
89
91
|
memos/memories/textual/tree_text_memory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
92
|
memos/memories/textual/tree_text_memory/organize/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
91
|
-
memos/memories/textual/tree_text_memory/organize/
|
|
93
|
+
memos/memories/textual/tree_text_memory/organize/conflict.py,sha256=AIJ3pZLPkYsOZE_AqqnCykaGsCk00wLZ8dAdpaz29uE,8462
|
|
94
|
+
memos/memories/textual/tree_text_memory/organize/manager.py,sha256=ZT0VZnvR-Nd3P3f2eu6YumoauMUmp94NVP90JpI9C5w,13486
|
|
95
|
+
memos/memories/textual/tree_text_memory/organize/redundancy.py,sha256=Z88OaNs5YvFY3liXDRFqPcdiIVdTTdlJ_esx3oOiRxI,9075
|
|
96
|
+
memos/memories/textual/tree_text_memory/organize/relation_reason_detector.py,sha256=gRG6iMT8Rm2Pk42UO1JzRaj3neIYmmOJmySi1knaGXA,8809
|
|
97
|
+
memos/memories/textual/tree_text_memory/organize/reorganizer.py,sha256=fy1P_9RWIiKBDayAfCviRZzJx48TMY09ynE0OenMX-o,22932
|
|
92
98
|
memos/memories/textual/tree_text_memory/retrieve/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
93
|
-
memos/memories/textual/tree_text_memory/retrieve/
|
|
99
|
+
memos/memories/textual/tree_text_memory/retrieve/internet_retriever.py,sha256=asSzVcSVOiigN4-4NzFc7wzthGDK6P5sODIDF5W9egA,8467
|
|
100
|
+
memos/memories/textual/tree_text_memory/retrieve/internet_retriever_factory.py,sha256=pBlufTc5-mdWcyKR_R0Syev3QPMtV83mydyIw0Saz4o,3192
|
|
101
|
+
memos/memories/textual/tree_text_memory/retrieve/reasoner.py,sha256=5csoGjviFbN9RJ8dm3B6kjvoC8xbPD8UMiGusefHaf0,2228
|
|
94
102
|
memos/memories/textual/tree_text_memory/retrieve/recall.py,sha256=a1P-L3ZER2wh6qTy6p2EhJ-6mSeSisbZgJnHjQv4XkM,5846
|
|
95
103
|
memos/memories/textual/tree_text_memory/retrieve/reranker.py,sha256=U_O0uEKpWHAURhSvkzjYoR2LC8v8vzBjRo8MTeW_6i4,3680
|
|
96
104
|
memos/memories/textual/tree_text_memory/retrieve/retrieval_mid_structs.py,sha256=jZs2S1jtd727gqDKs8clYCOwcqOBnrl_UmFU1FPE0w8,360
|
|
97
|
-
memos/memories/textual/tree_text_memory/retrieve/searcher.py,sha256=
|
|
98
|
-
memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py,sha256=
|
|
105
|
+
memos/memories/textual/tree_text_memory/retrieve/searcher.py,sha256=2TQsYxWXxZns7jQo1_5rZxbdjqReaQIzGDYJb9eZ4RM,8367
|
|
106
|
+
memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py,sha256=mAPxg5P3wmAvRVrutpeE3i2yC1R90egUUGdTWyWmq1U,2653
|
|
99
107
|
memos/memories/textual/tree_text_memory/retrieve/utils.py,sha256=JU9_3OTRp1lXHWV6SuRUIO_GjRCPclEu9MrjNZX_kck,1406
|
|
108
|
+
memos/memories/textual/tree_text_memory/retrieve/xinyusearch.py,sha256=0bewmGoHE2n-inHDMlHY2wfpGUzTPSRBm9JkGl63rag,10437
|
|
100
109
|
memos/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
110
|
memos/parsers/base.py,sha256=AWgWIZzReDiTqiv6z08_9aG2KHVzc4Bdr0Lowz0mWVI,435
|
|
102
111
|
memos/parsers/factory.py,sha256=hPKTR0wVgMQ5Z9ZL-a9FyHWCpz9UcrG2oSEDYBAoB3g,704
|
|
103
112
|
memos/parsers/markitdown.py,sha256=Yh7YAv8PFsz3WgegrwtA_hqaC9W4SOMZP7IRXxcnn_w,615
|
|
104
113
|
memos/settings.py,sha256=HYNBFRW0CS2Kh4GmMRMA-Yrh3ZhJno4S4B6gx6P3T30,178
|
|
105
114
|
memos/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
106
|
-
memos/templates/mem_reader_prompts.py,sha256=
|
|
115
|
+
memos/templates/mem_reader_prompts.py,sha256=tEsrlcYifQoSTZ0JXZr8Oo_--7zo3TPKAFoaHnDHTtE,7701
|
|
107
116
|
memos/templates/mem_scheduler_prompts.py,sha256=53bcOCC32790tVJ7_s7o0jwu6hg7jUs-z8dyahlLv24,2417
|
|
117
|
+
memos/templates/mos_prompts.py,sha256=QJrMb4FwMOAVb-SFSCGTuqqzvD_YhBTpdVBvpUIftK0,3595
|
|
118
|
+
memos/templates/tree_reorganize_prompts.py,sha256=5nN5m8tlxxy46Xz4x9bGhzMPkywVFKDFqvSCjK3xnTA,6347
|
|
108
119
|
memos/types.py,sha256=N7XBYxDTdc50KEsS6YxHvYgs23ykGsZ-wNnaJBVdVi4,1791
|
|
109
120
|
memos/vec_dbs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
110
121
|
memos/vec_dbs/base.py,sha256=a_-Gsh51C1_8R35mK7DykDxQTicmdgyz4fbEw8d5Mlg,3165
|
|
111
122
|
memos/vec_dbs/factory.py,sha256=Noa4caqzPT9b59i2jzdpAHFCSHiMfDmgRox1POkRRfE,710
|
|
112
123
|
memos/vec_dbs/item.py,sha256=mLrcHF0nWtMCUjScBgaeeSqabQ3vJhKr_6wrU_g25ns,1425
|
|
113
124
|
memos/vec_dbs/qdrant.py,sha256=I_XFmz_7SgFojMTFaqkPvwQEdMBl0MsCKZ43qatwuV0,9858
|
|
114
|
-
memoryos-0.
|
|
115
|
-
memoryos-0.
|
|
116
|
-
memoryos-0.
|
|
117
|
-
memoryos-0.
|
|
125
|
+
memoryos-0.2.0.dist-info/LICENSE,sha256=FU-b6N8tVc7dzUZGyNjUIG1Ihnrh2iuBziq4a1Gl8HU,11358
|
|
126
|
+
memoryos-0.2.0.dist-info/METADATA,sha256=q0T0qM5v5Dkq9J5kKBtahtGWUHlSsu7R_dT3O_0Rb1A,12636
|
|
127
|
+
memoryos-0.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
128
|
+
memoryos-0.2.0.dist-info/RECORD,,
|
memos/__init__.py
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Configuration classes for internet retrievers."""
|
|
2
|
+
|
|
3
|
+
from typing import Any, ClassVar
|
|
4
|
+
|
|
5
|
+
from pydantic import Field, field_validator, model_validator
|
|
6
|
+
|
|
7
|
+
from memos.configs.base import BaseConfig
|
|
8
|
+
from memos.exceptions import ConfigurationError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BaseInternetRetrieverConfig(BaseConfig):
|
|
12
|
+
"""Base configuration class for internet retrievers."""
|
|
13
|
+
|
|
14
|
+
api_key: str = Field(..., description="API key for the search service")
|
|
15
|
+
search_engine_id: str | None = Field(
|
|
16
|
+
None, description="Search engine ID (required for Google Custom Search)"
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class GoogleCustomSearchConfig(BaseInternetRetrieverConfig):
|
|
21
|
+
"""Configuration class for Google Custom Search API."""
|
|
22
|
+
|
|
23
|
+
search_engine_id: str = Field(..., description="Google Custom Search Engine ID (cx parameter)")
|
|
24
|
+
max_results: int = Field(default=20, description="Maximum number of results to retrieve")
|
|
25
|
+
num_per_request: int = Field(
|
|
26
|
+
default=10, description="Number of results per API request (max 10 for Google)"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class BingSearchConfig(BaseInternetRetrieverConfig):
|
|
31
|
+
"""Configuration class for Bing Search API."""
|
|
32
|
+
|
|
33
|
+
endpoint: str = Field(
|
|
34
|
+
default="https://api.bing.microsoft.com/v7.0/search", description="Bing Search API endpoint"
|
|
35
|
+
)
|
|
36
|
+
max_results: int = Field(default=20, description="Maximum number of results to retrieve")
|
|
37
|
+
num_per_request: int = Field(default=10, description="Number of results per API request")
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class XinyuSearchConfig(BaseInternetRetrieverConfig):
|
|
41
|
+
"""Configuration class for Xinyu Search API."""
|
|
42
|
+
|
|
43
|
+
search_engine_id: str | None = Field(
|
|
44
|
+
None, description="Not used for Xinyu Search (kept for compatibility)"
|
|
45
|
+
)
|
|
46
|
+
max_results: int = Field(default=20, description="Maximum number of results to retrieve")
|
|
47
|
+
num_per_request: int = Field(
|
|
48
|
+
default=10, description="Number of results per API request (not used for Xinyu)"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class InternetRetrieverConfigFactory(BaseConfig):
|
|
53
|
+
"""Factory class for creating internet retriever configurations."""
|
|
54
|
+
|
|
55
|
+
backend: str | None = Field(
|
|
56
|
+
None, description="Backend for internet retriever (google, bing, etc.)"
|
|
57
|
+
)
|
|
58
|
+
config: dict[str, Any] | None = Field(
|
|
59
|
+
None, description="Configuration for the internet retriever backend"
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
backend_to_class: ClassVar[dict[str, Any]] = {
|
|
63
|
+
"google": GoogleCustomSearchConfig,
|
|
64
|
+
"bing": BingSearchConfig,
|
|
65
|
+
"xinyu": XinyuSearchConfig,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@field_validator("backend")
|
|
69
|
+
@classmethod
|
|
70
|
+
def validate_backend(cls, backend: str | None) -> str | None:
|
|
71
|
+
"""Validate the backend field."""
|
|
72
|
+
if backend is not None and backend not in cls.backend_to_class:
|
|
73
|
+
raise ConfigurationError(f"Invalid internet retriever backend: {backend}")
|
|
74
|
+
return backend
|
|
75
|
+
|
|
76
|
+
@model_validator(mode="after")
|
|
77
|
+
def create_config(self) -> "InternetRetrieverConfigFactory":
|
|
78
|
+
if self.backend is not None:
|
|
79
|
+
config_class = self.backend_to_class[self.backend]
|
|
80
|
+
self.config = config_class(**self.config)
|
|
81
|
+
return self
|
memos/configs/llm.py
CHANGED
memos/configs/mem_os.py
CHANGED
|
@@ -57,6 +57,10 @@ class MOSConfig(BaseConfig):
|
|
|
57
57
|
default=False,
|
|
58
58
|
description="Enable memory scheduler for automated memory management",
|
|
59
59
|
)
|
|
60
|
+
PRO_MODE: bool = Field(
|
|
61
|
+
default=False,
|
|
62
|
+
description="Enable PRO mode for complex query decomposition",
|
|
63
|
+
)
|
|
60
64
|
|
|
61
65
|
|
|
62
66
|
class MemOSConfigFactory(BaseConfig):
|
memos/configs/mem_reader.py
CHANGED
|
@@ -22,6 +22,10 @@ class BaseMemReaderConfig(BaseConfig):
|
|
|
22
22
|
chunker: ChunkerConfigFactory = Field(
|
|
23
23
|
..., description="Chunker configuration for the MemReader"
|
|
24
24
|
)
|
|
25
|
+
remove_prompt_example: bool = Field(
|
|
26
|
+
default=False,
|
|
27
|
+
description="whether remove example in memory extraction prompt to save token",
|
|
28
|
+
)
|
|
25
29
|
|
|
26
30
|
|
|
27
31
|
class SimpleStructMemReaderConfig(BaseMemReaderConfig):
|
memos/configs/memory.py
CHANGED
|
@@ -5,6 +5,7 @@ from pydantic import Field, field_validator, model_validator
|
|
|
5
5
|
from memos.configs.base import BaseConfig
|
|
6
6
|
from memos.configs.embedder import EmbedderConfigFactory
|
|
7
7
|
from memos.configs.graph_db import GraphDBConfigFactory
|
|
8
|
+
from memos.configs.internet_retriever import InternetRetrieverConfigFactory
|
|
8
9
|
from memos.configs.llm import LLMConfigFactory
|
|
9
10
|
from memos.configs.vec_db import VectorDBConfigFactory
|
|
10
11
|
from memos.exceptions import ConfigurationError
|
|
@@ -133,7 +134,7 @@ class GeneralTextMemoryConfig(BaseTextMemoryConfig):
|
|
|
133
134
|
|
|
134
135
|
|
|
135
136
|
class TreeTextMemoryConfig(BaseTextMemoryConfig):
|
|
136
|
-
"""
|
|
137
|
+
"""Tree text memory configuration class."""
|
|
137
138
|
|
|
138
139
|
extractor_llm: LLMConfigFactory = Field(
|
|
139
140
|
...,
|
|
@@ -155,6 +156,15 @@ class TreeTextMemoryConfig(BaseTextMemoryConfig):
|
|
|
155
156
|
default_factory=GraphDBConfigFactory,
|
|
156
157
|
description="Graph database configuration for the tree-memory storage",
|
|
157
158
|
)
|
|
159
|
+
internet_retriever: InternetRetrieverConfigFactory | None = Field(
|
|
160
|
+
None,
|
|
161
|
+
description="Internet retriever configuration (optional)",
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
reorganize: bool | None = Field(
|
|
165
|
+
False,
|
|
166
|
+
description="Optional description for this memory configuration.",
|
|
167
|
+
)
|
|
158
168
|
|
|
159
169
|
|
|
160
170
|
# ─── 3. Global Memory Config Factory ──────────────────────────────────────────
|
memos/graph_dbs/item.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import uuid
|
|
2
|
+
|
|
3
|
+
from typing import Any, Literal
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
6
|
+
|
|
7
|
+
from memos.memories.textual.item import TextualMemoryItem
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GraphDBNode(TextualMemoryItem):
|
|
11
|
+
pass
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class GraphDBEdge(BaseModel):
|
|
15
|
+
"""Represents an edge in a graph database (corresponds to Neo4j relationship)."""
|
|
16
|
+
|
|
17
|
+
id: str = Field(
|
|
18
|
+
default_factory=lambda: str(uuid.uuid4()), description="Unique identifier for the edge"
|
|
19
|
+
)
|
|
20
|
+
source: str = Field(..., description="Source node ID")
|
|
21
|
+
target: str = Field(..., description="Target node ID")
|
|
22
|
+
type: Literal["RELATED", "PARENT"] = Field(
|
|
23
|
+
..., description="Relationship type (must be one of 'RELATED', 'PARENT')"
|
|
24
|
+
)
|
|
25
|
+
properties: dict[str, Any] | None = Field(
|
|
26
|
+
default=None, description="Additional properties for the edge"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
model_config = ConfigDict(extra="forbid")
|
|
30
|
+
|
|
31
|
+
@field_validator("id")
|
|
32
|
+
@classmethod
|
|
33
|
+
def validate_id(cls, v):
|
|
34
|
+
"""Validate that ID is a valid UUID."""
|
|
35
|
+
if not isinstance(v, str) or not uuid.UUID(v, version=4):
|
|
36
|
+
raise ValueError("ID must be a valid UUID string")
|
|
37
|
+
return v
|
|
38
|
+
|
|
39
|
+
@classmethod
|
|
40
|
+
def from_dict(cls, data: dict[str, Any]) -> "GraphDBEdge":
|
|
41
|
+
"""Create GraphDBEdge from dictionary."""
|
|
42
|
+
return cls(**data)
|
|
43
|
+
|
|
44
|
+
def to_dict(self) -> dict[str, Any]:
|
|
45
|
+
"""Convert to dictionary format."""
|
|
46
|
+
return self.model_dump(exclude_none=True)
|
memos/graph_dbs/neo4j.py
CHANGED
|
@@ -92,6 +92,16 @@ class Neo4jGraphDB(BaseGraphDB):
|
|
|
92
92
|
result = session.run(query, memory_type=memory_type)
|
|
93
93
|
return result.single()["count"]
|
|
94
94
|
|
|
95
|
+
def count_nodes(self, scope: str) -> int:
|
|
96
|
+
query = """
|
|
97
|
+
MATCH (n:Memory)
|
|
98
|
+
WHERE n.memory_type = $scope
|
|
99
|
+
RETURN count(n) AS count
|
|
100
|
+
"""
|
|
101
|
+
with self.driver.session(database=self.db_name) as session:
|
|
102
|
+
result = session.run(query, {"scope": scope}).single()
|
|
103
|
+
return result["count"]
|
|
104
|
+
|
|
95
105
|
def remove_oldest_memory(self, memory_type: str, keep_latest: int) -> None:
|
|
96
106
|
"""
|
|
97
107
|
Remove all WorkingMemory nodes except the latest `keep_latest` entries.
|
|
@@ -336,6 +346,49 @@ class Neo4jGraphDB(BaseGraphDB):
|
|
|
336
346
|
"""
|
|
337
347
|
raise NotImplementedError
|
|
338
348
|
|
|
349
|
+
def get_neighbors_by_tag(
|
|
350
|
+
self,
|
|
351
|
+
tags: list[str],
|
|
352
|
+
exclude_ids: list[str],
|
|
353
|
+
top_k: int = 5,
|
|
354
|
+
min_overlap: int = 1,
|
|
355
|
+
) -> list[dict[str, Any]]:
|
|
356
|
+
"""
|
|
357
|
+
Find top-K neighbor nodes with maximum tag overlap.
|
|
358
|
+
|
|
359
|
+
Args:
|
|
360
|
+
tags: The list of tags to match.
|
|
361
|
+
exclude_ids: Node IDs to exclude (e.g., local cluster).
|
|
362
|
+
top_k: Max number of neighbors to return.
|
|
363
|
+
min_overlap: Minimum number of overlapping tags required.
|
|
364
|
+
|
|
365
|
+
Returns:
|
|
366
|
+
List of dicts with node details and overlap count.
|
|
367
|
+
"""
|
|
368
|
+
query = """
|
|
369
|
+
MATCH (n:Memory)
|
|
370
|
+
WHERE NOT n.id IN $exclude_ids
|
|
371
|
+
AND n.status = 'activated'
|
|
372
|
+
AND n.type <> 'reasoning'
|
|
373
|
+
AND n.memory_type <> 'WorkingMemory'
|
|
374
|
+
WITH n, [tag IN n.tags WHERE tag IN $tags] AS overlap_tags
|
|
375
|
+
WHERE size(overlap_tags) >= $min_overlap
|
|
376
|
+
RETURN n, size(overlap_tags) AS overlap_count
|
|
377
|
+
ORDER BY overlap_count DESC
|
|
378
|
+
LIMIT $top_k
|
|
379
|
+
"""
|
|
380
|
+
|
|
381
|
+
params = {
|
|
382
|
+
"tags": tags,
|
|
383
|
+
"exclude_ids": exclude_ids,
|
|
384
|
+
"min_overlap": min_overlap,
|
|
385
|
+
"top_k": top_k,
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
with self.driver.session(database=self.db_name) as session:
|
|
389
|
+
result = session.run(query, params)
|
|
390
|
+
return [_parse_node(dict(record["n"])) for record in result]
|
|
391
|
+
|
|
339
392
|
def get_children_with_embeddings(self, id: str) -> list[str]:
|
|
340
393
|
query = """
|
|
341
394
|
MATCH (p:Memory)-[:PARENT]->(c:Memory)
|
|
@@ -386,14 +439,10 @@ class Neo4jGraphDB(BaseGraphDB):
|
|
|
386
439
|
record = session.run(query, {"center_id": center_id}).single()
|
|
387
440
|
|
|
388
441
|
if not record:
|
|
389
|
-
logger.warning(
|
|
390
|
-
f"No active node found for center_id={center_id} with status={center_status}"
|
|
391
|
-
)
|
|
392
442
|
return {"core_node": None, "neighbors": [], "edges": []}
|
|
393
443
|
|
|
394
444
|
centers = record["centers"]
|
|
395
445
|
if not centers or centers[0] is None:
|
|
396
|
-
logger.warning(f"Center node not found or inactive for id={center_id}")
|
|
397
446
|
return {"core_node": None, "neighbors": [], "edges": []}
|
|
398
447
|
|
|
399
448
|
core_node = _parse_node(dict(centers[0]))
|
|
@@ -730,6 +779,24 @@ class Neo4jGraphDB(BaseGraphDB):
|
|
|
730
779
|
results = session.run(query, {"scope": scope})
|
|
731
780
|
return [_parse_node(dict(record["n"])) for record in results]
|
|
732
781
|
|
|
782
|
+
def get_structure_optimization_candidates(self, scope: str) -> list[dict]:
|
|
783
|
+
"""
|
|
784
|
+
Find nodes that are likely candidates for structure optimization:
|
|
785
|
+
- Isolated nodes, nodes with empty background, or nodes with exactly one child.
|
|
786
|
+
- Plus: the child of any parent node that has exactly one child.
|
|
787
|
+
"""
|
|
788
|
+
query = """
|
|
789
|
+
MATCH (n:Memory)
|
|
790
|
+
WHERE n.memory_type = $scope
|
|
791
|
+
AND n.status = 'activated'
|
|
792
|
+
AND NOT ( (n)-[:PARENT]->() OR ()-[:PARENT]->(n) )
|
|
793
|
+
RETURN n.id AS id, n AS node
|
|
794
|
+
"""
|
|
795
|
+
|
|
796
|
+
with self.driver.session(database=self.db_name) as session:
|
|
797
|
+
results = session.run(query, {"scope": scope})
|
|
798
|
+
return [_parse_node({"id": record["id"], **dict(record["node"])}) for record in results]
|
|
799
|
+
|
|
733
800
|
def drop_database(self) -> None:
|
|
734
801
|
"""
|
|
735
802
|
Permanently delete the entire database this instance is using.
|
|
@@ -744,7 +811,7 @@ class Neo4jGraphDB(BaseGraphDB):
|
|
|
744
811
|
|
|
745
812
|
def _ensure_database_exists(self):
|
|
746
813
|
with self.driver.session(database="system") as session:
|
|
747
|
-
session.run(f"CREATE DATABASE
|
|
814
|
+
session.run(f"CREATE DATABASE $db_name IF NOT EXISTS", db_name=self.db_name)
|
|
748
815
|
|
|
749
816
|
# Wait until the database is available
|
|
750
817
|
for _ in range(10):
|
memos/llms/openai.py
CHANGED
|
@@ -22,6 +22,7 @@ class OpenAILLM(BaseLLM):
|
|
|
22
22
|
response = self.client.chat.completions.create(
|
|
23
23
|
model=self.config.model_name_or_path,
|
|
24
24
|
messages=messages,
|
|
25
|
+
extra_body=self.config.extra_body,
|
|
25
26
|
temperature=self.config.temperature,
|
|
26
27
|
max_tokens=self.config.max_tokens,
|
|
27
28
|
top_p=self.config.top_p,
|