Skip to content

Commit a2152f1

Browse files
committed
fix: update README.md
1 parent 809dde4 commit a2152f1

File tree

1 file changed

+120
-90
lines changed

1 file changed

+120
-90
lines changed

README.md

Lines changed: 120 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -117,98 +117,8 @@ showcasing its capabilities in **information extraction**, **temporal and cross-
117117
- **Textual Memory**: For storing and retrieving unstructured or structured text knowledge.
118118
- **Activation Memory**: Caches key-value pairs (`KVCacheMemory`) to accelerate LLM inference and context reuse.
119119
- **Parametric Memory**: Stores model adaptation parameters (e.g., LoRA weights).
120-
- **Tool Memory** 🆕: Records Agent tool call trajectories and experiences to improve planning capabilities.
121-
- **📚 Knowledge Base System** 🆕: Build multi-dimensional knowledge bases with automatic document/URL parsing, splitting, and cross-project sharing capabilities.
122-
- **🔧 Memory Controllability** 🆕:
123-
- **Feedback Mechanism**: Use `add_feedback` API to correct, supplement, or replace existing memories with natural language.
124-
- **Precise Deletion**: Delete specific memories by User ID or Memory ID via API or MCP tools.
125-
- **👁️ Multi-Modal Support** 🆕: Support for image understanding and memory, including chart parsing in documents.
126-
- **⚡ Advanced Architecture**:
127-
- **DB Optimization**: Enhanced connection management and batch insertion for high-concurrency scenarios.
128-
- **Advanced Retrieval**: Custom tag and info field filtering with complex logical operations.
129-
- **Redis Streams Scheduler**: Multi-level queue architecture with intelligent orchestration for fair multi-tenant scheduling.
130-
- **Stream & Non-Stream Chat**: Ready-to-use streaming and non-streaming chat interfaces.
131120
- **🔌 Extensible**: Easily extend and customize memory modules, data sources, and LLM integrations.
132-
- **🏂 Lightweight Deployment** 🆕: Support for quick mode and complete mode deployment options.
133121

134-
## 🚀 Getting Started
135-
136-
### ⭐️ MemOS online API
137-
The easiest way to use MemOS. Equip your agent with memory **in minutes**!
138-
139-
Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing).
140-
141-
142-
### Self-Hosted Server
143-
1. Get the repository.
144-
```bash
145-
git clone https://github.com/MemTensor/MemOS.git
146-
cd MemOS
147-
pip install -r ./docker/requirements.txt
148-
```
149-
150-
2. Configure `docker/.env.example` and copy to `MemOS/.env`
151-
3. Start the service.
152-
```bash
153-
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 8
154-
```
155-
156-
### Local SDK
157-
Here's a quick example of how to create a **`MemCube`**, load it from a directory, access its memories, and save it.
158-
159-
```python
160-
from memos.mem_cube.general import GeneralMemCube
161-
162-
# Initialize a MemCube from a local directory
163-
mem_cube = GeneralMemCube.init_from_dir("examples/data/mem_cube_2")
164-
165-
# Access and print all memories
166-
print("--- Textual Memories ---")
167-
for item in mem_cube.text_mem.get_all():
168-
print(item)
169-
170-
print("\n--- Activation Memories ---")
171-
for item in mem_cube.act_mem.get_all():
172-
print(item)
173-
174-
# Save the MemCube to a new directory
175-
mem_cube.dump("tmp/mem_cube")
176-
```
177-
178-
**`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:
179-
180-
```python
181-
from memos.configs.mem_os import MOSConfig
182-
from memos.mem_os.main import MOS
183-
184-
185-
# init MOS
186-
mos_config = MOSConfig.from_json_file("examples/data/config/simple_memos_config.json")
187-
memory = MOS(mos_config)
188-
189-
# create user
190-
user_id = "b41a34d5-5cae-4b46-8c49-d03794d206f5"
191-
memory.create_user(user_id=user_id)
192-
193-
# register cube for user
194-
memory.register_mem_cube("examples/data/mem_cube_2", user_id=user_id)
195-
196-
# add memory for user
197-
memory.add(
198-
messages=[
199-
{"role": "user", "content": "I like playing football."},
200-
{"role": "assistant", "content": "I like playing football too."},
201-
],
202-
user_id=user_id,
203-
)
204-
205-
# Later, when you want to retrieve memory for user
206-
retrieved_memories = memory.search(query="What do you like?", user_id=user_id)
207-
# output text_memories: I like playing football, act_memories, para_memories
208-
print(f"text_memories: {retrieved_memories['text_mem']}")
209-
```
210-
211-
For more detailed examples, please check out the [`examples`](./examples) directory.
212122

213123
## 📦 Installation
214124

@@ -259,6 +169,126 @@ To download example code, data and configurations, run the following command:
259169
memos download_examples
260170
```
261171

172+
## 🚀 Getting Started
173+
174+
### ⭐️ MemOS online API
175+
The easiest way to use MemOS. Equip your agent with memory **in minutes**!
176+
177+
Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing).
178+
179+
180+
### Self-Hosted Server
181+
1. Get the repository.
182+
```bash
183+
git clone https://github.com/MemTensor/MemOS.git
184+
cd MemOS
185+
pip install -r ./docker/requirements.txt
186+
```
187+
188+
2. Configure `docker/.env.example` and copy to `MemOS/.env`
189+
3. Start the service.
190+
```bash
191+
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 8
192+
```
193+
194+
### Interface SDK
195+
#### 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."},
208+
{"role": "user", "content": "I'll choose 7 Days"},
209+
{"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)
237+
from memos.api.client import MemOSClient
238+
239+
# Initialize the client using the API Key
240+
client = MemOSClient(api_key="YOUR_API_KEY")
241+
242+
user_ids = ["memos_user_123"]
243+
# Replace with the memory ID
244+
memory_ids = ["6b23b583-f4c4-4a8f-b345-58d0c48fea04"]
245+
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."
261+
# Replace with the knowledgebase ID
262+
allow_knowledgebase_ids = ["basee5ec9050-c964-484f-abf1-ce3e8e2aa5b7"]
263+
264+
res = client.add_feedback(
265+
user_id=user_id,
266+
conversation_id=conversation_id,
267+
feedback_content=feedback_content,
268+
allow_knowledgebase_ids=allow_knowledgebase_ids
269+
)
270+
271+
print(f"result: {res}")
272+
```
273+
274+
This interface is used to create a knowledgebase associated with a project
275+
```python
276+
# Please make sure MemoS is installed (pip install MemoryOS -U)
277+
from memos.api.client import MemOSClient
278+
279+
# Initialize the client using the API Key
280+
client = MemOSClient(api_key="YOUR_API_KEY")
281+
282+
knowledgebase_name = "Financial Reimbursement Knowledge Base"
283+
knowledgebase_description = "A compilation of all knowledge related to the company's financial reimbursements."
284+
285+
res = client.create_knowledgebase(
286+
knowledgebase_name=knowledgebase_name,
287+
knowledgebase_description=knowledgebase_description
288+
)
289+
print(f"result: {res}")
290+
```
291+
262292
## 💬 Community & Support
263293

264294
Join our community to ask questions, share your projects, and connect with other developers.

0 commit comments

Comments
 (0)