Skip to content

Commit 97e6211

Browse files
authored
Merge branch 'dev' into main
2 parents 40bc0c5 + 940dfde commit 97e6211

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3621
-1861
lines changed

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
---
4545

46-
<img src="https://statics.memtensor.com.cn/memos/sota_score.jpg" alt="SOTA SCORE">
46+
<img src="https://cdn.memtensor.com.cn/img/1762436050812_3tgird_compressed.png" alt="SOTA SCORE">
4747

4848
**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.
4949

@@ -52,6 +52,28 @@
5252
- **API Reference**: https://memos-docs.openmem.net/docs/api/info/
5353
- **Source Code**: https://github.com/MemTensor/MemOS
5454

55+
## 📰 News
56+
57+
Stay up to date with the latest MemOS announcements, releases, and community highlights.
58+
59+
60+
- **2025-11-06** - 🎉 MemOS v1.1.3 (Async Memory & Preference):
61+
Millisecond-level async memory add (support plain-text-memory and
62+
preference memory); enhanced BM25, graph recall, and mixture search; full
63+
results & code for LoCoMo, LongMemEval, PersonaMem, and PrefEval released.
64+
- **2025-10-30** - 🎉 MemOS v1.1.2 (API & MCP Update):
65+
API architecture overhaul and full MCP (Model Context Protocol) support — enabling models, IDEs, and agents to read/write external memory directly.
66+
- **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/)
67+
- **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.
68+
- **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.
69+
- **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.
70+
- **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.
71+
- **2025-07-07** – 🎉 *MemOS 1.0 (Stellar) Preview Release*: A SOTA Memory OS for LLMs is now open-sourced.
72+
- **2025-07-04** – 🎉 *MemOS Paper Released*: [MemOS: A Memory OS for AI System](https://arxiv.org/abs/2507.03724) was published on arXiv.
73+
- **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.
74+
- **2024-07-04** – 🎉 *Memory3 Model Released at WAIC 2024*: The new memory-layered architecture model was unveiled at the 2024 World Artificial Intelligence Conference.
75+
- **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.
76+
5577
## 📈 Performance Benchmark
5678

5779
MemOS demonstrates significant improvements over baseline memory solutions in multiple memory tasks,
@@ -265,19 +287,3 @@ We welcome contributions from the community! Please read our [contribution guide
265287
## 📄 License
266288

267289
MemOS is licensed under the [Apache 2.0 License](./LICENSE).
268-
269-
## 📰 News
270-
271-
Stay up to date with the latest MemOS announcements, releases, and community highlights.
272-
273-
274-
- **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/)
275-
- **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.
276-
- **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.
277-
- **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.
278-
- **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.
279-
- **2025-07-07** – 🎉 *MemOS 1.0 (Stellar) Preview Release*: A SOTA Memory OS for LLMs is now open-sourced.
280-
- **2025-07-04** – 🎉 *MemOS Paper Released*: [MemOS: A Memory OS for AI System](https://arxiv.org/abs/2507.03724) was published on arXiv.
281-
- **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.
282-
- **2024-07-04** – 🎉 *Memory3 Model Released at WAIC 2024*: The new memory-layered architecture model was unveiled at the 2024 World Artificial Intelligence Conference.
283-
- **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.

evaluation/.env-example

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ MEMU_API_KEY="mu_xxx"
2121
SUPERMEMORY_API_KEY="sm_xxx"
2222
MEMOBASE_API_KEY="xxx"
2323
MEMOBASE_PROJECT_URL="http://***.***.***.***:8019"
24-

examples/api/__init__.py

Whitespace-only changes.

examples/api/product_api.py

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Simulate full MemOS Product API workflow:
4+
1. Register user
5+
2. Add memory
6+
3. Search memory
7+
4. Chat (stream)
8+
"""
9+
10+
import json
11+
12+
import requests
13+
14+
15+
BASE_URL = "http://0.0.0.0:8001/product"
16+
HEADERS = {"Content-Type": "application/json"}
17+
18+
index = "24"
19+
USER_ID = f"memos_user_id_{index}"
20+
USER_NAME = f"memos_user_alice_{index}"
21+
MEM_CUBE_ID = f"memos_cube_id_{index}"
22+
SESSION_ID = f"memos_session_id_{index}"
23+
SESSION_ID2 = f"memos_session_id_{index}_s2"
24+
25+
26+
def register_user():
27+
url = f"{BASE_URL}/users/register"
28+
data = {
29+
"user_id": USER_ID,
30+
"user_name": USER_NAME,
31+
"interests": "memory,retrieval,test",
32+
"mem_cube_id": MEM_CUBE_ID,
33+
}
34+
print(f"[*] Registering user {USER_ID} ...")
35+
resp = requests.post(url, headers=HEADERS, data=json.dumps(data), timeout=30)
36+
print(resp.status_code, resp.text)
37+
return resp.json()
38+
39+
40+
def add_memory():
41+
url = f"{BASE_URL}/add"
42+
data = {
43+
"user_id": USER_ID,
44+
"memory_content": "今天我在测试 MemOS 的记忆添加与检索流程。",
45+
"messages": [{"role": "user", "content": "我今天在做系统测试"}],
46+
"doc_path": None,
47+
"mem_cube_id": MEM_CUBE_ID,
48+
"source": "test_script",
49+
"user_profile": False,
50+
"session_id": SESSION_ID,
51+
}
52+
print("[*] Adding memory ...")
53+
resp = requests.post(url, headers=HEADERS, data=json.dumps(data), timeout=30)
54+
print(resp.status_code, resp.text)
55+
return resp.json()
56+
57+
58+
def search_memory(query="系统测试"):
59+
url = f"{BASE_URL}/search"
60+
data = {
61+
"user_id": USER_ID,
62+
"query": query,
63+
"mem_cube_id": MEM_CUBE_ID,
64+
"top_k": 5,
65+
"session_id": SESSION_ID,
66+
}
67+
print("[*] Searching memory ...")
68+
resp = requests.post(url, headers=HEADERS, data=json.dumps(data), timeout=30)
69+
print(resp.status_code, resp.text)
70+
return resp.json()
71+
72+
73+
def chat_stream(query: str, session_id: str, history: list | None = None):
74+
url = f"{BASE_URL}/chat"
75+
data = {
76+
"user_id": USER_ID,
77+
"query": query,
78+
"mem_cube_id": MEM_CUBE_ID,
79+
"history": history,
80+
"internet_search": False,
81+
"moscube": False,
82+
"session_id": session_id,
83+
}
84+
85+
print("[*] Starting streaming chat ...")
86+
87+
with requests.post(url, headers=HEADERS, data=json.dumps(data), stream=True) as resp:
88+
for raw_line in resp.iter_lines():
89+
if not raw_line:
90+
continue
91+
line = raw_line.decode("utf-8", errors="ignore")
92+
93+
payload = line.removeprefix("data: ").strip()
94+
if payload == "[DONE]":
95+
print("[done]")
96+
break
97+
98+
try:
99+
msg = json.loads(payload)
100+
msg_type = msg.get("type")
101+
msg_data = msg.get("data") or msg.get("content")
102+
103+
if msg_type == "text":
104+
print(msg_data, end="", flush=True)
105+
elif msg_type == "reference":
106+
print(f"\n[参考记忆] {msg_data}")
107+
elif msg_type == "status":
108+
pass
109+
elif msg_type == "suggestion":
110+
print(f"\n[建议] {msg_data}")
111+
elif msg_type == "end":
112+
print("\n[✅ Chat End]")
113+
else:
114+
print(f"\n[{msg_type}] {msg_data}")
115+
except Exception:
116+
try:
117+
print(payload.encode("latin-1").decode("utf-8"), end="")
118+
except Exception:
119+
print(payload)
120+
121+
122+
if __name__ == "__main__":
123+
print("===== STEP 1: Register User =====")
124+
register_user()
125+
126+
print("\n===== STEP 2: Add Memory =====")
127+
add_memory()
128+
129+
print("\n===== STEP 3: Search Memory =====")
130+
search_memory()
131+
132+
print("\n===== STEP 4: Stream Chat =====")
133+
chat_stream("我很开心,我今天吃了好吃的拉面", SESSION_ID, history=[])
134+
chat_stream(
135+
"我刚和你说什么",
136+
SESSION_ID,
137+
history=[
138+
{"role": "user", "content": "我很开心,我今天吃了好吃的拉面"},
139+
{"role": "assistant", "content": "🉑"},
140+
],
141+
)
142+
143+
print("\n===== STEP 4: Stream Chat =====")
144+
chat_stream("我刚和你说什么了呢", SESSION_ID2, history=[])
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from memos.api.routers.server_router import mem_scheduler
2+
from memos.mem_scheduler.schemas.message_schemas import ScheduleMessageItem
3+
4+
5+
# Debug: Print scheduler configuration
6+
print("=== Scheduler Configuration Debug ===")
7+
print(f"Scheduler type: {type(mem_scheduler).__name__}")
8+
print(f"Config: {mem_scheduler.config}")
9+
print(f"use_redis_queue: {mem_scheduler.use_redis_queue}")
10+
print(f"Queue type: {type(mem_scheduler.memos_message_queue).__name__}")
11+
print(f"Queue maxsize: {getattr(mem_scheduler.memos_message_queue, 'maxsize', 'N/A')}")
12+
13+
# Check if Redis queue is connected
14+
if hasattr(mem_scheduler.memos_message_queue, "_is_connected"):
15+
print(f"Redis connected: {mem_scheduler.memos_message_queue._is_connected}")
16+
if hasattr(mem_scheduler.memos_message_queue, "_redis_conn"):
17+
print(f"Redis connection: {mem_scheduler.memos_message_queue._redis_conn}")
18+
print("=====================================\n")
19+
20+
queue = mem_scheduler.memos_message_queue
21+
queue.clear()
22+
23+
24+
# 1. Define a handler function
25+
def my_test_handler(messages: list[ScheduleMessageItem]):
26+
print(f"My test handler received {len(messages)} messages:")
27+
for msg in messages:
28+
print(f" my_test_handler - {msg.item_id}: {msg.content}")
29+
print(
30+
f"{queue._redis_conn.xinfo_groups(queue.stream_name)} qsize: {queue.qsize()} messages:{messages}"
31+
)
32+
33+
34+
# 2. Register the handler
35+
TEST_HANDLER_LABEL = "test_handler"
36+
mem_scheduler.register_handlers({TEST_HANDLER_LABEL: my_test_handler})
37+
38+
# 3. Create messages
39+
messages_to_send = [
40+
ScheduleMessageItem(
41+
item_id=f"test_item_{i}",
42+
user_id="test_user",
43+
mem_cube_id="test_mem_cube",
44+
label=TEST_HANDLER_LABEL,
45+
content=f"This is test message {i}",
46+
)
47+
for i in range(5)
48+
]
49+
50+
# 5. Submit messages
51+
for mes in messages_to_send:
52+
print(f"Submitting message {mes.item_id} to the scheduler...")
53+
mem_scheduler.submit_messages([mes])
54+
55+
# 6. Wait for messages to be processed (limited to 100 checks)
56+
print("Waiting for messages to be consumed (max 100 checks)...")
57+
mem_scheduler.mem_scheduler_wait()
58+
59+
60+
# 7. Stop the scheduler
61+
print("Stopping the scheduler...")
62+
mem_scheduler.stop()

examples/mem_scheduler/memos_w_optimized_scheduler.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)