You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
<!--
Please include a summary of the changes below;
Fill in the issue number that this PR addresses (if applicable);
Fill in the related MemOS-Docs repository issue or PR link (if
applicable);
Mention the person who will review this PR (if you know who it is);
Replace (summary), (issue), (docs-issue-or-pr-link), and (reviewer) with
the appropriate information.
请在下方填写更改的摘要;
填写此 PR 解决的问题编号(如果适用);
填写相关的 MemOS-Docs 仓库 issue 或 PR 链接(如果适用);
提及将审查此 PR 的人(如果您知道是谁);
替换 (summary)、(issue)、(docs-issue-or-pr-link) 和 (reviewer) 为适当的信息。
-->
Summary: (summary)
Fix: #(issue)
Docs Issue/PR: (docs-issue-or-pr-link)
Reviewer: @(reviewer)
## Checklist:
- [ ] I have performed a self-review of my own code | 我已自行检查了自己的代码
- [ ] I have commented my code in hard-to-understand areas |
我已在难以理解的地方对代码进行了注释
- [ ] I have added tests that prove my fix is effective or that my
feature works | 我已添加测试以证明我的修复有效或功能正常
- [ ] I have created related documentation issue/PR in
[MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) (if applicable) |
我已在 [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs) 中创建了相关的文档
issue/PR(如果适用)
- [ ] I have linked the issue to this PR (if applicable) | 我已将 issue
链接到此 PR(如果适用)
- [ ] I have mentioned the person who will review this PR | 我已提及将审查此 PR
的人
**`MOS`** (Memory Operating System) is a higher-level orchestration layer that manages multiple MemCubes and provides a unified API for memory operations. Here's a quick example of how to use MOS:
#### Here is a quick example showing how to create interface SDK
207
+
208
+
This interface is used to add messages, supporting multiple types of content and batch additions. MemOS will automatically parse the messages and handle memory for reference in subsequent conversations.
209
+
```python
210
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
211
+
from memos.api.client import MemOSClient
212
+
213
+
# Initialize the client using the API Key
214
+
client = MemOSClient(api_key="YOUR_API_KEY")
215
+
216
+
messages = [
217
+
{"role": "user", "content": "I have planned to travel to Guangzhou during the summer vacation. What chain hotels are available for accommodation?"},
218
+
{"role": "assistant", "content": "You can consider [7 Days, All Seasons, Hilton], and so on."},
{"role": "assistant", "content": "Okay, ask me if you have any other questions."}
221
+
]
222
+
user_id ="memos_user_123"
223
+
conversation_id ="0610"
224
+
res = client.add_message(messages=messages, user_id=user_id, conversation_id=conversation_id)
225
+
226
+
print(f"result: {res}")
227
+
```
228
+
229
+
This interface is used to retrieve the memories of a specified user, returning the memory fragments most relevant to the input query for Agent use. The recalled memory fragments include 'factual memory', 'preference memory', and 'tool memory'.
230
+
```python
231
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
232
+
from memos.api.client import MemOSClient
233
+
234
+
# Initialize the client using the API Key
235
+
client = MemOSClient(api_key="YOUR_API_KEY")
236
+
237
+
query ="I want to go out to play during National Day. Can you recommend a city I haven't been to and a hotel brand I haven't stayed at?"
238
+
user_id ="memos_user_123"
239
+
conversation_id ="0928"
240
+
res = client.search_memory(query=query, user_id=user_id, conversation_id=conversation_id)
241
+
242
+
print(f"result: {res}")
243
+
```
244
+
245
+
This interface is used to delete the memory of specified users and supports batch deletion.
246
+
```python
247
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
res = client.delete_memory(user_ids=user_ids, memory_ids=memory_ids)
257
+
258
+
print(f"result: {res}")
259
+
```
260
+
261
+
This interface is used to add feedback to messages in the current session, allowing MemOS to correct its memory based on user feedback.
262
+
```python
263
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
264
+
from memos.api.client import MemOSClient
265
+
266
+
# Initialize the client using the API Key
267
+
client = MemOSClient(api_key="YOUR_API_KEY")
268
+
269
+
user_id ="memos_user_123"
270
+
conversation_id ="memos_feedback_conv"
271
+
feedback_content ="No, let's change it now to a meal allowance of 150 yuan per day and a lodging subsidy of 700 yuan per day for first-tier cities; for second- and third-tier cities, it remains the same as before."
0 commit comments