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
**`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
196
+
197
+
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.
198
+
```python
199
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
200
+
from memos.api.client import MemOSClient
201
+
202
+
# Initialize the client using the API Key
203
+
client = MemOSClient(api_key="YOUR_API_KEY")
204
+
205
+
messages = [
206
+
{"role": "user", "content": "I have planned to travel to Guangzhou during the summer vacation. What chain hotels are available for accommodation?"},
207
+
{"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."}
210
+
]
211
+
user_id ="memos_user_123"
212
+
conversation_id ="0610"
213
+
res = client.add_message(messages=messages, user_id=user_id, conversation_id=conversation_id)
214
+
215
+
print(f"result: {res}")
216
+
```
217
+
218
+
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'.
219
+
```python
220
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
221
+
from memos.api.client import MemOSClient
222
+
223
+
# Initialize the client using the API Key
224
+
client = MemOSClient(api_key="YOUR_API_KEY")
225
+
226
+
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?"
227
+
user_id ="memos_user_123"
228
+
conversation_id ="0928"
229
+
res = client.search_memory(query=query, user_id=user_id, conversation_id=conversation_id)
230
+
231
+
print(f"result: {res}")
232
+
```
233
+
234
+
This interface is used to delete the memory of specified users and supports batch deletion.
235
+
```python
236
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
res = client.delete_memory(user_ids=user_ids, memory_ids=memory_ids)
246
+
247
+
print(f"result: {res}")
248
+
```
249
+
250
+
This interface is used to add feedback to messages in the current session, allowing MemOS to correct its memory based on user feedback.
251
+
```python
252
+
# Please make sure MemoS is installed (pip install MemoryOS -U)
253
+
from memos.api.client import MemOSClient
254
+
255
+
# Initialize the client using the API Key
256
+
client = MemOSClient(api_key="YOUR_API_KEY")
257
+
258
+
user_id ="memos_user_123"
259
+
conversation_id ="memos_feedback_conv"
260
+
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