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
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