MemoryOS 0.2.2__py3-none-any.whl → 1.0.1__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.2.2.dist-info → memoryos-1.0.1.dist-info}/METADATA +7 -1
- {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/RECORD +81 -66
- memos/__init__.py +1 -1
- memos/api/config.py +31 -8
- memos/api/context/context.py +1 -1
- memos/api/context/context_thread.py +96 -0
- memos/api/middleware/request_context.py +94 -0
- memos/api/product_api.py +5 -1
- memos/api/product_models.py +16 -0
- memos/api/routers/product_router.py +39 -3
- memos/api/start_api.py +3 -0
- memos/configs/internet_retriever.py +13 -0
- memos/configs/mem_scheduler.py +38 -16
- memos/configs/memory.py +13 -0
- memos/configs/reranker.py +18 -0
- memos/graph_dbs/base.py +33 -4
- memos/graph_dbs/nebular.py +631 -236
- memos/graph_dbs/neo4j.py +18 -7
- memos/graph_dbs/neo4j_community.py +6 -3
- memos/llms/vllm.py +2 -0
- memos/log.py +125 -8
- memos/mem_os/core.py +49 -11
- memos/mem_os/main.py +1 -1
- memos/mem_os/product.py +392 -215
- memos/mem_os/utils/default_config.py +1 -1
- memos/mem_os/utils/format_utils.py +11 -47
- memos/mem_os/utils/reference_utils.py +153 -0
- memos/mem_reader/simple_struct.py +112 -43
- memos/mem_scheduler/base_scheduler.py +58 -55
- memos/mem_scheduler/{modules → general_modules}/base.py +1 -2
- memos/mem_scheduler/{modules → general_modules}/dispatcher.py +54 -15
- memos/mem_scheduler/{modules → general_modules}/rabbitmq_service.py +4 -4
- memos/mem_scheduler/{modules → general_modules}/redis_service.py +1 -1
- memos/mem_scheduler/{modules → general_modules}/retriever.py +19 -5
- memos/mem_scheduler/{modules → general_modules}/scheduler_logger.py +10 -4
- memos/mem_scheduler/general_scheduler.py +110 -67
- memos/mem_scheduler/monitors/__init__.py +0 -0
- memos/mem_scheduler/monitors/dispatcher_monitor.py +305 -0
- memos/mem_scheduler/{modules/monitor.py → monitors/general_monitor.py} +57 -19
- memos/mem_scheduler/mos_for_test_scheduler.py +7 -1
- memos/mem_scheduler/schemas/general_schemas.py +3 -2
- memos/mem_scheduler/schemas/message_schemas.py +2 -1
- memos/mem_scheduler/schemas/monitor_schemas.py +10 -2
- memos/mem_scheduler/utils/misc_utils.py +43 -2
- memos/mem_user/mysql_user_manager.py +4 -2
- memos/memories/activation/item.py +1 -1
- memos/memories/activation/kv.py +20 -8
- memos/memories/textual/base.py +1 -1
- memos/memories/textual/general.py +1 -1
- memos/memories/textual/item.py +1 -1
- memos/memories/textual/tree.py +31 -1
- memos/memories/textual/tree_text_memory/organize/{conflict.py → handler.py} +30 -48
- memos/memories/textual/tree_text_memory/organize/manager.py +8 -96
- memos/memories/textual/tree_text_memory/organize/relation_reason_detector.py +2 -0
- memos/memories/textual/tree_text_memory/organize/reorganizer.py +102 -140
- memos/memories/textual/tree_text_memory/retrieve/bochasearch.py +231 -0
- memos/memories/textual/tree_text_memory/retrieve/internet_retriever_factory.py +9 -0
- memos/memories/textual/tree_text_memory/retrieve/recall.py +67 -10
- memos/memories/textual/tree_text_memory/retrieve/reranker.py +1 -1
- memos/memories/textual/tree_text_memory/retrieve/searcher.py +246 -134
- memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py +7 -2
- memos/memories/textual/tree_text_memory/retrieve/utils.py +7 -5
- memos/memos_tools/lockfree_dict.py +120 -0
- memos/memos_tools/notification_utils.py +46 -0
- memos/memos_tools/thread_safe_dict.py +288 -0
- memos/reranker/__init__.py +4 -0
- memos/reranker/base.py +24 -0
- memos/reranker/cosine_local.py +95 -0
- memos/reranker/factory.py +43 -0
- memos/reranker/http_bge.py +99 -0
- memos/reranker/noop.py +16 -0
- memos/templates/mem_reader_prompts.py +290 -39
- memos/templates/mem_scheduler_prompts.py +23 -10
- memos/templates/mos_prompts.py +133 -31
- memos/templates/tree_reorganize_prompts.py +24 -17
- memos/utils.py +19 -0
- memos/memories/textual/tree_text_memory/organize/redundancy.py +0 -193
- {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/LICENSE +0 -0
- {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/WHEEL +0 -0
- {memoryos-0.2.2.dist-info → memoryos-1.0.1.dist-info}/entry_points.txt +0 -0
- /memos/mem_scheduler/{modules → general_modules}/__init__.py +0 -0
- /memos/mem_scheduler/{modules → general_modules}/misc.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: MemoryOS
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.1
|
|
4
4
|
Summary: Intelligence Begins with Memory
|
|
5
5
|
License: Apache-2.0
|
|
6
6
|
Keywords: memory,llm,language model,memoryOS,agent,kv cache,lora
|
|
@@ -310,6 +310,12 @@ MemOS is licensed under the [Apache 2.0 License](./LICENSE).
|
|
|
310
310
|
|
|
311
311
|
Stay up to date with the latest MemOS announcements, releases, and community highlights.
|
|
312
312
|
|
|
313
|
+
|
|
314
|
+
- **2025-09-10** - 🎉 *MemOS v1.0.1 (Group Q&A Bot)*: Group Q&A bot based on MemOS Cube, updated KV-Cache performance comparison data across different GPU deployment schemes, optimized test benchmarks and statistics, added plaintext memory Reranker sorting, optimized plaintext memory hallucination issues, and Playground version updates. [Try PlayGround](https://memos-playground.openmem.net/login/)
|
|
315
|
+
- **2025-08-07** - 🎉 *MemOS v1.0.0 (MemCube Release)*: First MemCube with word game demo, LongMemEval evaluation, BochaAISearchRetriever integration, NebulaGraph support, enhanced search capabilities, and official Playground launch.
|
|
316
|
+
- **2025-07-29** – 🎉 *MemOS v0.2.2 (Nebula Update)*: Internet search+Nebula DB integration, refactored memory scheduler, KV Cache stress tests, MemCube Cookbook release (CN/EN), and 4b/1.7b/0.6b memory ops models.
|
|
317
|
+
- **2025-07-21** – 🎉 *MemOS v0.2.1 (Neo Release)*: Lightweight Neo version with plaintext+KV Cache functionality, Docker/multi-tenant support, MCP expansion, and new Cookbook/Mud game examples.
|
|
318
|
+
- **2025-07-11** – 🎉 *MemOS v0.2.0 (Cross-Platform)*: Added doc search/bilingual UI, MemReader-4B (local deploy), full Win/Mac/Linux support, and playground end-to-end connection.
|
|
313
319
|
- **2025-07-07** – 🎉 *MemOS 1.0 (Stellar) Preview Release*: A SOTA Memory OS for LLMs is now open-sourced.
|
|
314
320
|
- **2025-07-04** – 🎉 *MemOS Paper Released*: [MemOS: A Memory OS for AI System](https://arxiv.org/abs/2507.03724) was published on arXiv.
|
|
315
321
|
- **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.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
memos/__init__.py,sha256=
|
|
2
|
-
memos/api/config.py,sha256=
|
|
3
|
-
memos/api/context/context.py,sha256=
|
|
1
|
+
memos/__init__.py,sha256=EKtqQioVRZ2gNPD65cxhBbX-ZhswH1EBGMj2G6roYME,575
|
|
2
|
+
memos/api/config.py,sha256=Gx3g5jPZ_8EUPTTvA7h14tKL7VYe4FI4NybCTuylWuE,24513
|
|
3
|
+
memos/api/context/context.py,sha256=HBMeg3-e-rOJXMU7aR0JCsEIECuefEx8eyFT-1sSG9c,4158
|
|
4
|
+
memos/api/context/context_thread.py,sha256=T3Vdu7m1l8JMmoUBop1ykyrbH-oZ-_6FnymXsawmLis,3121
|
|
4
5
|
memos/api/context/dependencies.py,sha256=byLwmFsocQufcmi5WFg2j6XjWv9k4PCozCV7uRdCO3M,2468
|
|
5
6
|
memos/api/exceptions.py,sha256=MfTNXwLwJE7tHwNVTHlJsB3kF14oA0JfA1-S8xrZEus,833
|
|
6
7
|
memos/api/mcp_serve.py,sha256=GtJDZYx4yxKMs4sCddKJbRAjgsbRunr6S2nAT-KeBMs,21270
|
|
7
|
-
memos/api/
|
|
8
|
-
memos/api/
|
|
8
|
+
memos/api/middleware/request_context.py,sha256=8tkyIQkgBnGRM_X33CaM6x1M4jsprPMmYspTtRT20u8,2834
|
|
9
|
+
memos/api/product_api.py,sha256=6JrQRIGj1UrFxcHL2myA5_4li6Tf5S5ynja5rX3XhYU,1129
|
|
10
|
+
memos/api/product_models.py,sha256=aZJov3NqAaLpRLGPIg-GK6G00X-NvK2QyuOkQdCCmo8,6449
|
|
9
11
|
memos/api/routers/__init__.py,sha256=nbduRsr-7RkfBIYEBkbYkpB-7GG7QZgNfEQwLHbDXpI,21
|
|
10
|
-
memos/api/routers/product_router.py,sha256=
|
|
11
|
-
memos/api/start_api.py,sha256=
|
|
12
|
+
memos/api/routers/product_router.py,sha256=jeosTAJzwWkqo0Ev2eaHQex-LQtyI9LRLhLIvFDiOyw,17160
|
|
13
|
+
memos/api/start_api.py,sha256=rVXMPEQy9r1PiVzHO3LJCf2qSsb0Mv0tklUJMQMBP8A,14776
|
|
12
14
|
memos/chunkers/__init__.py,sha256=7lZOTN3e9Yp5XBsDX5wnWJ3tY126cRU9GmfevzJXAtU,67
|
|
13
15
|
memos/chunkers/base.py,sha256=z0rG5vM7FGremQdSZ_3jlTGbsDtlkWAYWdtSAGqpaR4,655
|
|
14
16
|
memos/chunkers/factory.py,sha256=ixpYz41GG3SZW-1ynLvfbhOZ0aGnFi2wUIYT4_Uxh30,693
|
|
@@ -19,16 +21,17 @@ memos/configs/base.py,sha256=bOOhEU6HGFTq5jne_TXn8Br72rvAfJHYvYllFUPs12A,2588
|
|
|
19
21
|
memos/configs/chunker.py,sha256=Ulci0MyhS_FkuV95l7Pr9Vei179aEFEUigwVmtmSDfI,1593
|
|
20
22
|
memos/configs/embedder.py,sha256=e_aOkUamW2NYSBEzsKkw0jNqHERy5GU3A2cSH5G5y68,2750
|
|
21
23
|
memos/configs/graph_db.py,sha256=800e8PqiXTaOBX-GQHRP9f3Gx-0Ma7fnO0pdA5WHJ0k,5868
|
|
22
|
-
memos/configs/internet_retriever.py,sha256=
|
|
24
|
+
memos/configs/internet_retriever.py,sha256=yWU6avRU9Hqox8hmR0EyILUr4x9wDvcKkhwRwT3PROc,3749
|
|
23
25
|
memos/configs/llm.py,sha256=cso9ZBOdPzOAcgypp2nPFHdynswdG9MZZ-qdgOTEXL8,4175
|
|
24
26
|
memos/configs/mem_chat.py,sha256=TjEQHRG1HpLwCBo3hrn5aVK23rykNtV6Be5p4YIg7F4,2571
|
|
25
27
|
memos/configs/mem_cube.py,sha256=k95dvNxusnyS9w6ciWgNkUXwbHa4HTUEUS-PfPbR0BM,3105
|
|
26
28
|
memos/configs/mem_os.py,sha256=FGrBaFWGUdCKkb4MFDRz9hCE7hydLd0XEFgUrqEhQJw,2755
|
|
27
29
|
memos/configs/mem_reader.py,sha256=hTLFdmPhPIY70Fh_s4ptTGJ3LN-B9n111QG1kboxoNk,2307
|
|
28
|
-
memos/configs/mem_scheduler.py,sha256=
|
|
30
|
+
memos/configs/mem_scheduler.py,sha256=kLE1JZM2IkzpsEdvJ0D0w3MNbjsqfB_--EvdZomHB5s,7644
|
|
29
31
|
memos/configs/mem_user.py,sha256=U0UzCvTacUOxeajJMfXAWWy3a0l52B4LUhH_L7U1VQ4,2036
|
|
30
|
-
memos/configs/memory.py,sha256=
|
|
32
|
+
memos/configs/memory.py,sha256=wWrDvO67evM4Pn-utqneliIsJlap0ddNhdEH1Vn8HbA,7636
|
|
31
33
|
memos/configs/parser.py,sha256=dy-QoevJbCnkJePKgpzR4oziOzYnS4jB6XH-YrpeMns,1145
|
|
34
|
+
memos/configs/reranker.py,sha256=8IbKPPNUcGq9uGhgXcx41eYjDJr1lZKv89UKrA9v-Ck,459
|
|
32
35
|
memos/configs/utils.py,sha256=X9NQ6-xURsZROAdS3WT96phVfHcOHgDPOo2Yq68QoKM,242
|
|
33
36
|
memos/configs/vec_db.py,sha256=Gjhhda94pyTDjyJGe2Z6rVEqH4FtViiwq1-7QWhjarM,2335
|
|
34
37
|
memos/dependency.py,sha256=T5jhi9J6EQvx41dP8ma6hdCNn86d1amEP1iMASnrVbA,1842
|
|
@@ -42,12 +45,12 @@ memos/embedders/sentence_transformer.py,sha256=QJoW7qMbvAzmMUXzIhMHXVFnDFurfzxdo
|
|
|
42
45
|
memos/embedders/universal_api.py,sha256=BpmLL18y2neEAIE4CdC-1qr0uOEOJ6o7V_zycdkJmZk,1270
|
|
43
46
|
memos/exceptions.py,sha256=UnBoZUYdwb1KoQPE-pXSLT4yOjkwxse9fx0rb_MhEzo,531
|
|
44
47
|
memos/graph_dbs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
|
-
memos/graph_dbs/base.py,sha256
|
|
48
|
+
memos/graph_dbs/base.py,sha256=0NXdXII-UmX_bqUhBVpFdxRURLAK8sIFFZg51J9QzV0,8293
|
|
46
49
|
memos/graph_dbs/factory.py,sha256=N1NaABiNnYvnsB-L82LrQaLvND5seCabFdSDsD8LoyA,932
|
|
47
50
|
memos/graph_dbs/item.py,sha256=BfK17hA_hHu7I348jWugP_rb9GS5hpKfgqtYGGHBohk,1450
|
|
48
|
-
memos/graph_dbs/nebular.py,sha256=
|
|
49
|
-
memos/graph_dbs/neo4j.py,sha256=
|
|
50
|
-
memos/graph_dbs/neo4j_community.py,sha256=
|
|
51
|
+
memos/graph_dbs/nebular.py,sha256=AgoMapzTVSbuIz4-mTwj9aBhepS8PkcxJp9_s4uWitI,63674
|
|
52
|
+
memos/graph_dbs/neo4j.py,sha256=sBlFCibQOtfO8c6bYQl_K9VsphJorfzx97UMQnrZs3E,42491
|
|
53
|
+
memos/graph_dbs/neo4j_community.py,sha256=lWvfSo_-Dt3ST4vmBQiaziZDtQHV9CwY0qmWajOSPsc,11521
|
|
51
54
|
memos/hello_world.py,sha256=RV1vXfK1_U_xAvSusqc-4A8wk3yr8WEQ9q88dmBxvnI,3057
|
|
52
55
|
memos/llms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
56
|
memos/llms/base.py,sha256=CF60OpXdSLf-B5bHhQTnomMEkrNCg-SHauu1vo8HpeU,798
|
|
@@ -59,8 +62,8 @@ memos/llms/ollama.py,sha256=r1HMvSvG_m8gFfwLJhTriJdB6VzKEqz9f9JFs2RJGTw,2732
|
|
|
59
62
|
memos/llms/openai.py,sha256=yOcdG320q0JFLi7ipHDXoPWpvyeOMFwbzrnXtk2xqec,3832
|
|
60
63
|
memos/llms/qwen.py,sha256=RFVoC_hxFe4dhCQ583fbTcT1AC3jDrKH0r6cDsZ0Cmo,2459
|
|
61
64
|
memos/llms/utils.py,sha256=OcbM9iSpFJpio7sTT5wvxVx-JnqjIx7eSgiRk7dt0ZI,292
|
|
62
|
-
memos/llms/vllm.py,sha256=
|
|
63
|
-
memos/log.py,sha256=
|
|
65
|
+
memos/llms/vllm.py,sha256=9ZEgTUyRk86Wp2deQH0o1oW2GbHQ7C3evi-McELyT2Q,5792
|
|
66
|
+
memos/log.py,sha256=bmOqq0lH-FkLOlNnYtppqdchkDTz7AjJuSuGUKhsxXQ,6362
|
|
64
67
|
memos/mem_chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
65
68
|
memos/mem_chat/base.py,sha256=LICB_mwUkdCVKb_r33GEPbrEr-2v3dEnI54cAvhcEew,830
|
|
66
69
|
memos/mem_chat/factory.py,sha256=KKCDG9FrpfY2hD3iJ4GM9x8dN09dyhstP1cOUH_knrY,720
|
|
@@ -70,48 +73,51 @@ memos/mem_cube/base.py,sha256=NoZKz16oO5AAnJ0alcY52Z1c3C1rbGRe8Znz0CCzDnw,864
|
|
|
70
73
|
memos/mem_cube/general.py,sha256=w1HbDIM7MD6Pu_Pbv4KHgQlxOMaCHvvJk_tmA9rZ_q8,8370
|
|
71
74
|
memos/mem_cube/utils.py,sha256=gDwiRo9VEvaTaRDzjWOGAH13ALRRV9bvUG7A-wy4KTA,5522
|
|
72
75
|
memos/mem_os/client.py,sha256=0M-WRTlQr7fDAYtq4B8dsMR0PfmyvD-ySMhKcW3Umd0,43
|
|
73
|
-
memos/mem_os/core.py,sha256=
|
|
74
|
-
memos/mem_os/main.py,sha256=
|
|
75
|
-
memos/mem_os/product.py,sha256=
|
|
76
|
-
memos/mem_os/utils/default_config.py,sha256=
|
|
77
|
-
memos/mem_os/utils/format_utils.py,sha256=
|
|
76
|
+
memos/mem_os/core.py,sha256=3PccrYDzheOKDW8_ZAwzXKvR8Rz4JHfvrdG4vSu6Ttg,45543
|
|
77
|
+
memos/mem_os/main.py,sha256=zjgQy80QN70Xt6GHqn5zw-_2jOT6RWMCh9Yx-3zZuyw,24534
|
|
78
|
+
memos/mem_os/product.py,sha256=_tloS0ncPx04qfwKbggNFQzk0VL5Nqx6uHQriAFZYzI,58877
|
|
79
|
+
memos/mem_os/utils/default_config.py,sha256=OdDCyrE3-duSK0vMfO4AelGUwMt14ffHKMrvki0YKlI,12273
|
|
80
|
+
memos/mem_os/utils/format_utils.py,sha256=QaxImCM0E27l2tkRLzWM1s8vSp3MO_LNaY0APHgV35o,49883
|
|
81
|
+
memos/mem_os/utils/reference_utils.py,sha256=RtVwcuG3zFaxtMxY4S1_S8XWKQ7hO5UtXMswORBxyy0,6129
|
|
78
82
|
memos/mem_reader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
79
83
|
memos/mem_reader/base.py,sha256=SSuaD3J88XbHsME1Qa-EAgZ57xApPHPHppMSeeS3JZ4,957
|
|
80
84
|
memos/mem_reader/factory.py,sha256=emKnId9BhScSkqCZyLSLWntixnU3wAMIOVdsRpHldJA,766
|
|
81
85
|
memos/mem_reader/memory.py,sha256=f3fAjrs8Jf6mBZWTgzkEZle7XjDwTJHxM1L2sOb85Tg,13288
|
|
82
|
-
memos/mem_reader/simple_struct.py,sha256=
|
|
86
|
+
memos/mem_reader/simple_struct.py,sha256=TTYGOVt5WNwRpaHF0TW6VkVC98HbeS9-IA6dpIlHmpY,11864
|
|
83
87
|
memos/mem_scheduler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
|
-
memos/mem_scheduler/base_scheduler.py,sha256=
|
|
85
|
-
memos/mem_scheduler/
|
|
86
|
-
memos/mem_scheduler/
|
|
87
|
-
memos/mem_scheduler/
|
|
88
|
-
memos/mem_scheduler/
|
|
89
|
-
memos/mem_scheduler/
|
|
90
|
-
memos/mem_scheduler/
|
|
91
|
-
memos/mem_scheduler/
|
|
92
|
-
memos/mem_scheduler/
|
|
93
|
-
memos/mem_scheduler/
|
|
94
|
-
memos/mem_scheduler/
|
|
95
|
-
memos/mem_scheduler/
|
|
88
|
+
memos/mem_scheduler/base_scheduler.py,sha256=wxBmdsJUmiufQLEfqflb4EUs9h9JE1EcMdsr_CA-LKE,23255
|
|
89
|
+
memos/mem_scheduler/general_modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
90
|
+
memos/mem_scheduler/general_modules/base.py,sha256=j2FfGl5mx0CflHGnzu2fFFfZT_WRAMzmmTW_HUxFRgw,2946
|
|
91
|
+
memos/mem_scheduler/general_modules/dispatcher.py,sha256=weDMAumIFJORJnpIm_8epz5d5pZ3XFx23O_0k-UONww,7375
|
|
92
|
+
memos/mem_scheduler/general_modules/misc.py,sha256=qtHx_M3O0p01-bdje5xp4YbTYcU6rpoRsDvPikxOU-s,3574
|
|
93
|
+
memos/mem_scheduler/general_modules/rabbitmq_service.py,sha256=kXfL8Q7eo8H2OMUDhAotbYG9cpL89HDJ5h7A64caKrw,12620
|
|
94
|
+
memos/mem_scheduler/general_modules/redis_service.py,sha256=oHa9EvrpkknGAeygjmc8tExyCJVOU_7SZU6ScMOT9pY,5898
|
|
95
|
+
memos/mem_scheduler/general_modules/retriever.py,sha256=6BiT-rxdXNnlDJjikQVwuy279W0tePo7tbb6j8c8j6s,7849
|
|
96
|
+
memos/mem_scheduler/general_modules/scheduler_logger.py,sha256=8nzdjCd6I4-KRPwLjdf8eXcSQ0i_-xK6rAbQ3j1-GrA,9985
|
|
97
|
+
memos/mem_scheduler/general_scheduler.py,sha256=oPGSvXKzFVYDr0YFnjS42zFYydHOXqlWd1woZ83CptA,14743
|
|
98
|
+
memos/mem_scheduler/monitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
99
|
+
memos/mem_scheduler/monitors/dispatcher_monitor.py,sha256=xy3fFa_vM5PpVHWweMTh3V3bZmnccWV49x0nBNFAVVw,10930
|
|
100
|
+
memos/mem_scheduler/monitors/general_monitor.py,sha256=pv_T-olU0XTO44-rXgfqX43nmDEp8iq-rwlMyAA0Lxk,12962
|
|
101
|
+
memos/mem_scheduler/mos_for_test_scheduler.py,sha256=kioG5V27V8jfXxFA9OHpKoULNF697eGToVo7z-U3mqQ,5950
|
|
96
102
|
memos/mem_scheduler/scheduler_factory.py,sha256=pw6FKO0EuxFRipMnD22DvcjbM6pdmVfJmRjUvdTaU5E,800
|
|
97
103
|
memos/mem_scheduler/schemas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
98
|
-
memos/mem_scheduler/schemas/general_schemas.py,sha256=
|
|
99
|
-
memos/mem_scheduler/schemas/message_schemas.py,sha256=
|
|
100
|
-
memos/mem_scheduler/schemas/monitor_schemas.py,sha256=
|
|
104
|
+
memos/mem_scheduler/schemas/general_schemas.py,sha256=r9Ew8KHTVxiDTTLKad1jw12uNMyLltFmn2htplSqbhk,1344
|
|
105
|
+
memos/mem_scheduler/schemas/message_schemas.py,sha256=ahTEY6x8gSXszURne1nKgHCkfEXfKOEXaTKTUsQ9IW0,5977
|
|
106
|
+
memos/mem_scheduler/schemas/monitor_schemas.py,sha256=OvFwchhFCvkHnp8k7NYAQQ5Lq7N0cNKA0mSEasNRLkU,12715
|
|
101
107
|
memos/mem_scheduler/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
102
108
|
memos/mem_scheduler/utils/filter_utils.py,sha256=GsEsVjB6zZbF2gITxXN1DWTLoLG-d8A3TFnGzy1uIaQ,6286
|
|
103
|
-
memos/mem_scheduler/utils/misc_utils.py,sha256
|
|
109
|
+
memos/mem_scheduler/utils/misc_utils.py,sha256=zOCpwzCrj0mfiW7BoWiTFEPj-dzdcYZnqMDtKDGO0kc,2765
|
|
104
110
|
memos/mem_user/factory.py,sha256=zdC-208YYU4dpUaMpICzNbhMTiLaJDxLJoq4bl-6YiU,2956
|
|
105
111
|
memos/mem_user/mysql_persistent_user_manager.py,sha256=fSndxW6MR7u9ImWCPq-gsuFb2TYX1BXF6Kkv1FCS6Fw,9257
|
|
106
|
-
memos/mem_user/mysql_user_manager.py,sha256=
|
|
112
|
+
memos/mem_user/mysql_user_manager.py,sha256=Q_3FxNTw8Vf6uPotHk4YUooa8EVo0jBFTFBKJHPm_6o,16331
|
|
107
113
|
memos/mem_user/persistent_factory.py,sha256=0_k3KgvVESOAoD35ecwY77Dam-rfaFlly9oL-eMFmhk,3170
|
|
108
114
|
memos/mem_user/persistent_user_manager.py,sha256=oKQ6uXlT6v-bWTe99E5mNoPvs9FOxPtaMzNL4zujzP0,8760
|
|
109
115
|
memos/mem_user/user_manager.py,sha256=-Dwo8oR0AbnCGY9s3utm2ZqOvTJCpDTF5hlkvPRNiqA,15654
|
|
110
116
|
memos/memories/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
111
117
|
memos/memories/activation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
112
118
|
memos/memories/activation/base.py,sha256=kiC35AOnuofgYMzLxZyVULsfOoVq03BGvi6AXtNvF-I,1151
|
|
113
|
-
memos/memories/activation/item.py,sha256=
|
|
114
|
-
memos/memories/activation/kv.py,sha256=
|
|
119
|
+
memos/memories/activation/item.py,sha256=8oo3odhNnvg36NYLobwkehAHj74mo36IcH2MrlXSCEI,1720
|
|
120
|
+
memos/memories/activation/kv.py,sha256=c3rhOowxqmYnUnVKGT1XqsHQurl44Ht98wCDz42laP8,8903
|
|
115
121
|
memos/memories/activation/vllmkv.py,sha256=QM6Y8a3dhqGa08_5rbE-JTR4EakNgoEEVfLdVcvmgms,7765
|
|
116
122
|
memos/memories/base.py,sha256=Sr-dEuDc982WwdVREQ2nL8L6rUc0KZPTaBJeYdgx8h8,577
|
|
117
123
|
memos/memories/factory.py,sha256=Z49DRF_VHQJI2UNiTJ_1ouPqg_iCcuV_Tcg5fXkKxlM,1418
|
|
@@ -120,50 +126,59 @@ memos/memories/parametric/base.py,sha256=RQK2LeaMRr2rVbfoa0M7RJx4r0dGD_uBXt73eiz
|
|
|
120
126
|
memos/memories/parametric/item.py,sha256=9FcY7kf53Uvl5FGXn23o2c0dI_9aUcYjUqTxKOMlbuI,219
|
|
121
127
|
memos/memories/parametric/lora.py,sha256=TqSI2OjmFi-XXCeM-MchSwh1sAhOwL7_JnOwSy9qpis,1397
|
|
122
128
|
memos/memories/textual/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
123
|
-
memos/memories/textual/base.py,sha256=
|
|
124
|
-
memos/memories/textual/general.py,sha256=
|
|
125
|
-
memos/memories/textual/item.py,sha256=
|
|
129
|
+
memos/memories/textual/base.py,sha256=5AQ0oR1rLd7yiwIKPxt2OmAlL6mWhwUl_U8zuafoDfI,2827
|
|
130
|
+
memos/memories/textual/general.py,sha256=exHPHejBE6jZNLm8pT951sIko8hAqNdOaHZdnNdfzBA,8877
|
|
131
|
+
memos/memories/textual/item.py,sha256=GR6V0GNn32W-pYtwSvmz5F6kTh39Yp4XrQm-cEghL2I,5259
|
|
126
132
|
memos/memories/textual/naive.py,sha256=Z_gfbxI6cQGJ_raOTQic4fnpo493Xq3yEQ8qDV4xplo,6954
|
|
127
|
-
memos/memories/textual/tree.py,sha256=
|
|
133
|
+
memos/memories/textual/tree.py,sha256=7RwwWYm5c_F0pNMnQDjcCV01NGb_t-yN_kU8EMZjB9g,14826
|
|
128
134
|
memos/memories/textual/tree_text_memory/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
129
135
|
memos/memories/textual/tree_text_memory/organize/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
130
|
-
memos/memories/textual/tree_text_memory/organize/
|
|
131
|
-
memos/memories/textual/tree_text_memory/organize/manager.py,sha256=
|
|
132
|
-
memos/memories/textual/tree_text_memory/organize/
|
|
133
|
-
memos/memories/textual/tree_text_memory/organize/
|
|
134
|
-
memos/memories/textual/tree_text_memory/organize/reorganizer.py,sha256=eCFONhtd-o2f_LRXbkDg6gIpJRpDKhG1z_RbRHE2-eg,24031
|
|
136
|
+
memos/memories/textual/tree_text_memory/organize/handler.py,sha256=l7WuwWvubGzgaOSUBS0VNjSQU2JxtjwLMtKHxpms8NQ,8139
|
|
137
|
+
memos/memories/textual/tree_text_memory/organize/manager.py,sha256=r-0O9hS3y3oQrTaKOulLmbsquk_FW6eEPse6tf7AuVM,9783
|
|
138
|
+
memos/memories/textual/tree_text_memory/organize/relation_reason_detector.py,sha256=udqQEFZb6TiarB-Rya1N7fKiWHtXiLkggh8bFKIlDjU,8816
|
|
139
|
+
memos/memories/textual/tree_text_memory/organize/reorganizer.py,sha256=txBC6uo3fId4RaTJeTJEg4V3Q-jrIP0jBHqVQkjjAqc,22719
|
|
135
140
|
memos/memories/textual/tree_text_memory/retrieve/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
141
|
+
memos/memories/textual/tree_text_memory/retrieve/bochasearch.py,sha256=Nh9nbOD3MPcofD4jM0Mihb7cjE17VTvPEsuuMTzisM4,8258
|
|
136
142
|
memos/memories/textual/tree_text_memory/retrieve/internet_retriever.py,sha256=aD2bujlVBWzDa9ZfB9vdB9Hq2erCpc426AVcolItWIM,8656
|
|
137
|
-
memos/memories/textual/tree_text_memory/retrieve/internet_retriever_factory.py,sha256=
|
|
143
|
+
memos/memories/textual/tree_text_memory/retrieve/internet_retriever_factory.py,sha256=3-hJwpGrAAag7z772QBvW9ZBvNI_od5GO1nRv5Q3GbQ,3767
|
|
138
144
|
memos/memories/textual/tree_text_memory/retrieve/reasoner.py,sha256=5csoGjviFbN9RJ8dm3B6kjvoC8xbPD8UMiGusefHaf0,2228
|
|
139
|
-
memos/memories/textual/tree_text_memory/retrieve/recall.py,sha256=
|
|
140
|
-
memos/memories/textual/tree_text_memory/retrieve/reranker.py,sha256=
|
|
145
|
+
memos/memories/textual/tree_text_memory/retrieve/recall.py,sha256=oGTp-14af1ZCHd8zkKP4vZ9F6gb3F9hGPdGp70AtiVA,7841
|
|
146
|
+
memos/memories/textual/tree_text_memory/retrieve/reranker.py,sha256=GIo_ZqA8Oea-L58Md724ak7Oq2fCnLfBWBUvMWiD7mY,3727
|
|
141
147
|
memos/memories/textual/tree_text_memory/retrieve/retrieval_mid_structs.py,sha256=CvGfdwtOwC78OWKb1nOg_tsPualirsRfbtA58_kxNpA,433
|
|
142
|
-
memos/memories/textual/tree_text_memory/retrieve/searcher.py,sha256=
|
|
143
|
-
memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py,sha256=
|
|
144
|
-
memos/memories/textual/tree_text_memory/retrieve/utils.py,sha256=
|
|
148
|
+
memos/memories/textual/tree_text_memory/retrieve/searcher.py,sha256=18o-qlcLI0Fv6H-wRYcPf3ez6kcVjUt37TIbzEl7naM,12854
|
|
149
|
+
memos/memories/textual/tree_text_memory/retrieve/task_goal_parser.py,sha256=vqgyczpS5As9zmljX9YF7TL0fgpl_T22FN5qV_AbcS8,3733
|
|
150
|
+
memos/memories/textual/tree_text_memory/retrieve/utils.py,sha256=ISdSJEq_HqtPEqmTRQO6dXx7ioDWrbLi7mrrep4iQDw,2191
|
|
145
151
|
memos/memories/textual/tree_text_memory/retrieve/xinyusearch.py,sha256=x-nlZJ84shgAq9FqQR3YvE6iTMY_B7Pc0YaiGEqM1rc,10518
|
|
146
152
|
memos/memos_tools/dinding_report_bot.py,sha256=kXmooO_wUpwErT6Obql-SQu8lbt0XnM_58znIeQt734,14735
|
|
153
|
+
memos/memos_tools/lockfree_dict.py,sha256=A2hFUSyjTIauiXONYzr7zFZfGlOF9J9cqrfzDNBaw_w,3811
|
|
147
154
|
memos/memos_tools/notification_service.py,sha256=CZ7tZI6m0A063ON0MVEOUb9uontggvrvBLOMzorD0cI,1125
|
|
148
|
-
memos/memos_tools/notification_utils.py,sha256=
|
|
155
|
+
memos/memos_tools/notification_utils.py,sha256=uHrDOXEW-WUJcoeR7gVhr2BVjNYUxIjz8cCve5F1PPs,3747
|
|
156
|
+
memos/memos_tools/thread_safe_dict.py,sha256=5hhKndKntYIriTIkmaDaehmojuOMhEkVl4WAc2QLfHM,8252
|
|
149
157
|
memos/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
150
158
|
memos/parsers/base.py,sha256=AWgWIZzReDiTqiv6z08_9aG2KHVzc4Bdr0Lowz0mWVI,435
|
|
151
159
|
memos/parsers/factory.py,sha256=hPKTR0wVgMQ5Z9ZL-a9FyHWCpz9UcrG2oSEDYBAoB3g,704
|
|
152
160
|
memos/parsers/markitdown.py,sha256=SDwmZYC6LyiwdU79yuj6mWNMkQx9YrZzZEHU-4JzBwQ,863
|
|
161
|
+
memos/reranker/__init__.py,sha256=bq3LWhVg6LdK50Hx6jOM-eWEaNM0mX4_JuHNfYgUqE0,69
|
|
162
|
+
memos/reranker/base.py,sha256=bl9W-CqtlAs2k7loPvd3TRqq6Illybt6IosqrYw0DHw,573
|
|
163
|
+
memos/reranker/cosine_local.py,sha256=tOqL6WIUxkFriaROV0hKtJQ-b79BGGYD4Ow1VE0x0g0,2970
|
|
164
|
+
memos/reranker/factory.py,sha256=RMBKOLSgmhfvbhCqU8CnQrXR7176zjq04VD6PMDrxuk,1321
|
|
165
|
+
memos/reranker/http_bge.py,sha256=BFlRMqspV856EGinjkI_Vr2oo6YBeF00uDy_eeTT-k0,3254
|
|
166
|
+
memos/reranker/noop.py,sha256=OOy3d_AHydCm5BH4VNHEfq_vDE-D-WBgwSKIp8GQloo,414
|
|
153
167
|
memos/settings.py,sha256=BYOaqhzReu2yjbwrZqx9-uMwoipkj5Clc6VthnBYOvY,225
|
|
154
168
|
memos/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
155
|
-
memos/templates/mem_reader_prompts.py,sha256=
|
|
156
|
-
memos/templates/mem_scheduler_prompts.py,sha256=
|
|
157
|
-
memos/templates/mos_prompts.py,sha256=
|
|
158
|
-
memos/templates/tree_reorganize_prompts.py,sha256=
|
|
169
|
+
memos/templates/mem_reader_prompts.py,sha256=B1sWIuZbIQM1zTv-VAWDsHUNLdO1O6fCy9WdhLMq2Aw,26875
|
|
170
|
+
memos/templates/mem_scheduler_prompts.py,sha256=ty_H9TARf5sQogHSJoRYQmrS6w0xs51mMcKNjkExdFc,5034
|
|
171
|
+
memos/templates/mos_prompts.py,sha256=yqpf8n0ObJPrJjXg4x-Nxsd0_pr0cDhdyCOopI7sgbI,18321
|
|
172
|
+
memos/templates/tree_reorganize_prompts.py,sha256=FJRIwT2A4d5EnoPhNuzDFdMWpbNLlJEIfLZP69RBlDM,12112
|
|
159
173
|
memos/types.py,sha256=N7XBYxDTdc50KEsS6YxHvYgs23ykGsZ-wNnaJBVdVi4,1791
|
|
174
|
+
memos/utils.py,sha256=uB-8_5V16M7yNeAYXOIPaXwxeceUu4d_5yofLA6vbaE,428
|
|
160
175
|
memos/vec_dbs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
161
176
|
memos/vec_dbs/base.py,sha256=gbw7Gb_zs8Yx8kJIx6aTM-Ylsb4qLkVOFB-iwNJW6Sw,3564
|
|
162
177
|
memos/vec_dbs/factory.py,sha256=Noa4caqzPT9b59i2jzdpAHFCSHiMfDmgRox1POkRRfE,710
|
|
163
178
|
memos/vec_dbs/item.py,sha256=mLrcHF0nWtMCUjScBgaeeSqabQ3vJhKr_6wrU_g25ns,1425
|
|
164
179
|
memos/vec_dbs/qdrant.py,sha256=4KAiSZ64Ulz8EeT2o1DpNDRwnKRF4iiaJbZdq-xrn0c,11052
|
|
165
|
-
memoryos-0.
|
|
166
|
-
memoryos-0.
|
|
167
|
-
memoryos-0.
|
|
168
|
-
memoryos-0.
|
|
169
|
-
memoryos-0.
|
|
180
|
+
memoryos-1.0.1.dist-info/LICENSE,sha256=FU-b6N8tVc7dzUZGyNjUIG1Ihnrh2iuBziq4a1Gl8HU,11358
|
|
181
|
+
memoryos-1.0.1.dist-info/METADATA,sha256=PvCovFOrn2QX_LoH22DuSjJQZwgl9rxgjVJvCfQMfxo,16011
|
|
182
|
+
memoryos-1.0.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
183
|
+
memoryos-1.0.1.dist-info/entry_points.txt,sha256=p54si8po81Yb-NK2lx5Z0lNr8QV7-5IECtkC6c8MJmI,40
|
|
184
|
+
memoryos-1.0.1.dist-info/RECORD,,
|
memos/__init__.py
CHANGED
memos/api/config.py
CHANGED
|
@@ -90,6 +90,29 @@ class APIConfig:
|
|
|
90
90
|
},
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
@staticmethod
|
|
94
|
+
def get_reranker_config() -> dict[str, Any]:
|
|
95
|
+
"""Get embedder configuration."""
|
|
96
|
+
embedder_backend = os.getenv("MOS_RERANKER_BACKEND", "http_bge")
|
|
97
|
+
|
|
98
|
+
if embedder_backend == "http_bge":
|
|
99
|
+
return {
|
|
100
|
+
"backend": "http_bge",
|
|
101
|
+
"config": {
|
|
102
|
+
"url": os.getenv("MOS_RERANKER_URL"),
|
|
103
|
+
"model": "bge-reranker-v2-m3",
|
|
104
|
+
"timeout": 10,
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
else:
|
|
108
|
+
return {
|
|
109
|
+
"backend": "cosine_local",
|
|
110
|
+
"config": {
|
|
111
|
+
"level_weights": {"topic": 1.0, "concept": 1.0, "fact": 1.0},
|
|
112
|
+
"level_field": "background",
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
|
|
93
116
|
@staticmethod
|
|
94
117
|
def get_embedder_config() -> dict[str, Any]:
|
|
95
118
|
"""Get embedder configuration."""
|
|
@@ -100,9 +123,9 @@ class APIConfig:
|
|
|
100
123
|
"backend": "universal_api",
|
|
101
124
|
"config": {
|
|
102
125
|
"provider": os.getenv("MOS_EMBEDDER_PROVIDER", "openai"),
|
|
103
|
-
"api_key": os.getenv("
|
|
126
|
+
"api_key": os.getenv("MOS_EMBEDDER_API_KEY", "sk-xxxx"),
|
|
104
127
|
"model_name_or_path": os.getenv("MOS_EMBEDDER_MODEL", "text-embedding-3-large"),
|
|
105
|
-
"base_url": os.getenv("
|
|
128
|
+
"base_url": os.getenv("MOS_EMBEDDER_API_BASE", "http://openai.com"),
|
|
106
129
|
},
|
|
107
130
|
}
|
|
108
131
|
else: # ollama
|
|
@@ -120,10 +143,9 @@ class APIConfig:
|
|
|
120
143
|
def get_internet_config() -> dict[str, Any]:
|
|
121
144
|
"""Get embedder configuration."""
|
|
122
145
|
return {
|
|
123
|
-
"backend": "
|
|
146
|
+
"backend": "bocha",
|
|
124
147
|
"config": {
|
|
125
|
-
"api_key": os.getenv("
|
|
126
|
-
"search_engine_id": os.getenv("XINYU_SEARCH_ENGINE_ID"),
|
|
148
|
+
"api_key": os.getenv("BOCHA_API_KEY"),
|
|
127
149
|
"max_results": 15,
|
|
128
150
|
"num_per_request": 10,
|
|
129
151
|
"reader": {
|
|
@@ -137,7 +159,7 @@ class APIConfig:
|
|
|
137
159
|
"max_tokens": 5000,
|
|
138
160
|
"top_p": 0.95,
|
|
139
161
|
"top_k": 20,
|
|
140
|
-
"api_key": "EMPTY",
|
|
162
|
+
"api_key": os.getenv("MEMRADER_API_KEY", "EMPTY"),
|
|
141
163
|
"api_base": os.getenv("MEMRADER_API_BASE"),
|
|
142
164
|
"remove_think_prefix": True,
|
|
143
165
|
"extra_body": {"chat_template_kwargs": {"enable_thinking": False}},
|
|
@@ -252,7 +274,6 @@ class APIConfig:
|
|
|
252
274
|
"backend": "general_scheduler",
|
|
253
275
|
"config": {
|
|
254
276
|
"top_k": int(os.getenv("MOS_SCHEDULER_TOP_K", "10")),
|
|
255
|
-
"top_n": int(os.getenv("MOS_SCHEDULER_TOP_N", "5")),
|
|
256
277
|
"act_mem_update_interval": int(
|
|
257
278
|
os.getenv("MOS_SCHEDULER_ACT_MEM_UPDATE_INTERVAL", "300")
|
|
258
279
|
),
|
|
@@ -267,7 +288,7 @@ class APIConfig:
|
|
|
267
288
|
"MOS_SCHEDULER_ENABLE_PARALLEL_DISPATCH", "true"
|
|
268
289
|
).lower()
|
|
269
290
|
== "true",
|
|
270
|
-
"
|
|
291
|
+
"enable_activation_memory": True,
|
|
271
292
|
},
|
|
272
293
|
}
|
|
273
294
|
|
|
@@ -494,6 +515,7 @@ class APIConfig:
|
|
|
494
515
|
},
|
|
495
516
|
"embedder": APIConfig.get_embedder_config(),
|
|
496
517
|
"internet_retriever": internet_config,
|
|
518
|
+
"reranker": APIConfig.get_reranker_config(),
|
|
497
519
|
},
|
|
498
520
|
},
|
|
499
521
|
"act_mem": {}
|
|
@@ -547,6 +569,7 @@ class APIConfig:
|
|
|
547
569
|
"config": graph_db_backend_map[graph_db_backend],
|
|
548
570
|
},
|
|
549
571
|
"embedder": APIConfig.get_embedder_config(),
|
|
572
|
+
"reranker": APIConfig.get_reranker_config(),
|
|
550
573
|
"reorganize": os.getenv("MOS_ENABLE_REORGANIZE", "false").lower()
|
|
551
574
|
== "true",
|
|
552
575
|
"internet_retriever": internet_config,
|
memos/api/context/context.py
CHANGED
|
@@ -122,7 +122,7 @@ def set_trace_id_getter(getter: TraceIdGetter) -> None:
|
|
|
122
122
|
Set a custom trace_id getter function.
|
|
123
123
|
|
|
124
124
|
This allows the logging system to retrieve trace_id without importing
|
|
125
|
-
API-specific
|
|
125
|
+
API-specific general_modules.
|
|
126
126
|
"""
|
|
127
127
|
global _trace_id_getter
|
|
128
128
|
_trace_id_getter = getter
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import threading
|
|
3
|
+
|
|
4
|
+
from collections.abc import Callable
|
|
5
|
+
from concurrent.futures import ThreadPoolExecutor
|
|
6
|
+
from typing import Any, TypeVar
|
|
7
|
+
|
|
8
|
+
from memos.api.context.context import (
|
|
9
|
+
RequestContext,
|
|
10
|
+
get_current_context,
|
|
11
|
+
get_current_trace_id,
|
|
12
|
+
set_request_context,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
T = TypeVar("T")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ContextThread(threading.Thread):
|
|
20
|
+
"""
|
|
21
|
+
Thread class that automatically propagates the main thread's trace_id to child threads.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(self, target, args=(), kwargs=None, **thread_kwargs):
|
|
25
|
+
super().__init__(**thread_kwargs)
|
|
26
|
+
self.target = target
|
|
27
|
+
self.args = args
|
|
28
|
+
self.kwargs = kwargs or {}
|
|
29
|
+
|
|
30
|
+
self.main_trace_id = get_current_trace_id()
|
|
31
|
+
self.main_context = get_current_context()
|
|
32
|
+
|
|
33
|
+
def run(self):
|
|
34
|
+
# Create a new RequestContext with the main thread's trace_id
|
|
35
|
+
if self.main_context:
|
|
36
|
+
# Copy the context data
|
|
37
|
+
child_context = RequestContext(trace_id=self.main_trace_id)
|
|
38
|
+
child_context._data = self.main_context._data.copy()
|
|
39
|
+
|
|
40
|
+
# Set the context in the child thread
|
|
41
|
+
set_request_context(child_context)
|
|
42
|
+
|
|
43
|
+
# Run the target function
|
|
44
|
+
self.target(*self.args, **self.kwargs)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ContextThreadPoolExecutor(ThreadPoolExecutor):
|
|
48
|
+
"""
|
|
49
|
+
ThreadPoolExecutor that automatically propagates the main thread's trace_id to worker threads.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def submit(self, fn: Callable[..., T], *args: Any, **kwargs: Any) -> Any:
|
|
53
|
+
"""
|
|
54
|
+
Submit a callable to be executed with the given arguments.
|
|
55
|
+
Automatically propagates the current thread's context to the worker thread.
|
|
56
|
+
"""
|
|
57
|
+
main_trace_id = get_current_trace_id()
|
|
58
|
+
main_context = get_current_context()
|
|
59
|
+
|
|
60
|
+
@functools.wraps(fn)
|
|
61
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
62
|
+
if main_context:
|
|
63
|
+
# Create and set new context in worker thread
|
|
64
|
+
child_context = RequestContext(trace_id=main_trace_id)
|
|
65
|
+
child_context._data = main_context._data.copy()
|
|
66
|
+
set_request_context(child_context)
|
|
67
|
+
|
|
68
|
+
return fn(*args, **kwargs)
|
|
69
|
+
|
|
70
|
+
return super().submit(wrapper, *args, **kwargs)
|
|
71
|
+
|
|
72
|
+
def map(
|
|
73
|
+
self,
|
|
74
|
+
fn: Callable[..., T],
|
|
75
|
+
*iterables: Any,
|
|
76
|
+
timeout: float | None = None,
|
|
77
|
+
chunksize: int = 1,
|
|
78
|
+
) -> Any:
|
|
79
|
+
"""
|
|
80
|
+
Returns an iterator equivalent to map(fn, iter).
|
|
81
|
+
Automatically propagates the current thread's context to worker threads.
|
|
82
|
+
"""
|
|
83
|
+
main_trace_id = get_current_trace_id()
|
|
84
|
+
main_context = get_current_context()
|
|
85
|
+
|
|
86
|
+
@functools.wraps(fn)
|
|
87
|
+
def wrapper(*args: Any, **kwargs: Any) -> Any:
|
|
88
|
+
if main_context:
|
|
89
|
+
# Create and set new context in worker thread
|
|
90
|
+
child_context = RequestContext(trace_id=main_trace_id)
|
|
91
|
+
child_context._data = main_context._data.copy()
|
|
92
|
+
set_request_context(child_context)
|
|
93
|
+
|
|
94
|
+
return fn(*args, **kwargs)
|
|
95
|
+
|
|
96
|
+
return super().map(wrapper, *iterables, timeout=timeout, chunksize=chunksize)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Request context middleware for automatic trace_id injection.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import logging
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
from collections.abc import Callable
|
|
9
|
+
|
|
10
|
+
from starlette.middleware.base import BaseHTTPMiddleware
|
|
11
|
+
from starlette.requests import Request
|
|
12
|
+
from starlette.responses import Response
|
|
13
|
+
|
|
14
|
+
from memos.api.context.context import RequestContext, set_request_context
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def generate_trace_id() -> str:
|
|
21
|
+
"""Generate a random trace_id."""
|
|
22
|
+
return os.urandom(16).hex()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def extract_trace_id_from_headers(request: Request) -> str | None:
|
|
26
|
+
"""Extract trace_id from various possible headers with priority: g-trace-id > x-trace-id > trace-id."""
|
|
27
|
+
trace_id = request.headers.get("g-trace-id")
|
|
28
|
+
if trace_id:
|
|
29
|
+
return trace_id
|
|
30
|
+
|
|
31
|
+
trace_id = request.headers.get("x-trace-id")
|
|
32
|
+
if trace_id:
|
|
33
|
+
return trace_id
|
|
34
|
+
|
|
35
|
+
trace_id = request.headers.get("trace-id")
|
|
36
|
+
if trace_id:
|
|
37
|
+
return trace_id
|
|
38
|
+
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class RequestContextMiddleware(BaseHTTPMiddleware):
|
|
43
|
+
"""
|
|
44
|
+
Middleware to automatically inject request context for every HTTP request.
|
|
45
|
+
|
|
46
|
+
This middleware:
|
|
47
|
+
1. Extracts trace_id from headers or generates a new one
|
|
48
|
+
2. Creates a RequestContext and sets it globally
|
|
49
|
+
3. Ensures the context is available throughout the request lifecycle
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
async def dispatch(self, request: Request, call_next: Callable) -> Response:
|
|
53
|
+
# Extract or generate trace_id
|
|
54
|
+
trace_id = extract_trace_id_from_headers(request)
|
|
55
|
+
if not trace_id:
|
|
56
|
+
trace_id = generate_trace_id()
|
|
57
|
+
|
|
58
|
+
# Create and set request context
|
|
59
|
+
context = RequestContext(trace_id=trace_id)
|
|
60
|
+
set_request_context(context)
|
|
61
|
+
|
|
62
|
+
# Add request metadata to context
|
|
63
|
+
context.set("method", request.method)
|
|
64
|
+
context.set("path", request.url.path)
|
|
65
|
+
context.set("client_ip", request.client.host if request.client else None)
|
|
66
|
+
|
|
67
|
+
# Log request start with parameters
|
|
68
|
+
params_log = {}
|
|
69
|
+
|
|
70
|
+
# Get query parameters
|
|
71
|
+
if request.query_params:
|
|
72
|
+
params_log["query_params"] = dict(request.query_params)
|
|
73
|
+
|
|
74
|
+
# Get request body if it's available
|
|
75
|
+
try:
|
|
76
|
+
params_log = await request.json()
|
|
77
|
+
except Exception as e:
|
|
78
|
+
logger.error(f"Error getting request body: {e}")
|
|
79
|
+
# If body is not JSON or empty, ignore it
|
|
80
|
+
|
|
81
|
+
logger.info(
|
|
82
|
+
f"Request started: {request.method} {request.url.path} - Parameters: {params_log}"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Process the request
|
|
86
|
+
response = await call_next(request)
|
|
87
|
+
|
|
88
|
+
# Log request completion with output
|
|
89
|
+
logger.info(f"Request completed: {request.url.path}, status: {response.status_code}")
|
|
90
|
+
|
|
91
|
+
# Add trace_id to response headers for debugging
|
|
92
|
+
response.headers["x-trace-id"] = trace_id
|
|
93
|
+
|
|
94
|
+
return response
|
memos/api/product_api.py
CHANGED
|
@@ -3,6 +3,7 @@ import logging
|
|
|
3
3
|
from fastapi import FastAPI
|
|
4
4
|
|
|
5
5
|
from memos.api.exceptions import APIExceptionHandler
|
|
6
|
+
from memos.api.middleware.request_context import RequestContextMiddleware
|
|
6
7
|
from memos.api.routers.product_router import router as product_router
|
|
7
8
|
|
|
8
9
|
|
|
@@ -13,9 +14,12 @@ logger = logging.getLogger(__name__)
|
|
|
13
14
|
app = FastAPI(
|
|
14
15
|
title="MemOS Product REST APIs",
|
|
15
16
|
description="A REST API for managing multiple users with MemOS Product.",
|
|
16
|
-
version="1.0.
|
|
17
|
+
version="1.0.1",
|
|
17
18
|
)
|
|
18
19
|
|
|
20
|
+
# Add request context middleware (must be added first)
|
|
21
|
+
app.add_middleware(RequestContextMiddleware)
|
|
22
|
+
|
|
19
23
|
# Include routers
|
|
20
24
|
app.include_router(product_router)
|
|
21
25
|
|
memos/api/product_models.py
CHANGED
|
@@ -84,6 +84,21 @@ class ChatRequest(BaseRequest):
|
|
|
84
84
|
mem_cube_id: str | None = Field(None, description="Cube ID to use for chat")
|
|
85
85
|
history: list[MessageDict] | None = Field(None, description="Chat history")
|
|
86
86
|
internet_search: bool = Field(True, description="Whether to use internet search")
|
|
87
|
+
moscube: bool = Field(False, description="Whether to use MemOSCube")
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class ChatCompleteRequest(BaseRequest):
|
|
91
|
+
"""Request model for chat operations."""
|
|
92
|
+
|
|
93
|
+
user_id: str = Field(..., description="User ID")
|
|
94
|
+
query: str = Field(..., description="Chat query message")
|
|
95
|
+
mem_cube_id: str | None = Field(None, description="Cube ID to use for chat")
|
|
96
|
+
history: list[MessageDict] | None = Field(None, description="Chat history")
|
|
97
|
+
internet_search: bool = Field(False, description="Whether to use internet search")
|
|
98
|
+
moscube: bool = Field(False, description="Whether to use MemOSCube")
|
|
99
|
+
base_prompt: str | None = Field(None, description="Base prompt to use for chat")
|
|
100
|
+
top_k: int = Field(10, description="Number of results to return")
|
|
101
|
+
threshold: float = Field(0.5, description="Threshold for filtering references")
|
|
87
102
|
|
|
88
103
|
|
|
89
104
|
class UserCreate(BaseRequest):
|
|
@@ -161,3 +176,4 @@ class SuggestionRequest(BaseRequest):
|
|
|
161
176
|
|
|
162
177
|
user_id: str = Field(..., description="User ID")
|
|
163
178
|
language: Literal["zh", "en"] = Field("zh", description="Language for suggestions")
|
|
179
|
+
message: list[MessageDict] | None = Field(None, description="List of messages to store.")
|