Skip to content

Commit d42ec55

Browse files
authored
Main zhq readme (#794)
## 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 的人
2 parents 35af8f6 + 02abdcc commit d42ec55

File tree

2 files changed

+86
-132
lines changed

2 files changed

+86
-132
lines changed

README.md

Lines changed: 85 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -131,88 +131,32 @@ showcasing its capabilities in **information extraction**, **temporal and cross-
131131
- **🔌 Extensible**: Easily extend and customize memory modules, data sources, and LLM integrations.
132132
- **🏂 Lightweight Deployment** 🆕: Support for quick mode and complete mode deployment options.
133133

134-
## 📦 Installation
135134

136-
### Install via pip
137-
138-
```bash
139-
pip install MemoryOS
140-
```
141-
142-
### Optional Dependencies
143-
144-
MemOS provides several optional dependency groups for different features. You can install them based on your needs.
145-
146-
| Feature | Package Name |
147-
| --------------------- | ------------------------- |
148-
| Tree Memory | `MemoryOS[tree-mem]` |
149-
| Memory Reader | `MemoryOS[mem-reader]` |
150-
| Memory Scheduler | `MemoryOS[mem-scheduler]` |
151-
152-
Example installation commands:
153-
154-
```bash
155-
pip install MemoryOS[tree-mem]
156-
pip install MemoryOS[tree-mem,mem-reader]
157-
pip install MemoryOS[mem-scheduler]
158-
pip install MemoryOS[tree-mem,mem-reader,mem-scheduler]
159-
```
160-
161-
### External Dependencies
162-
163-
#### Ollama Support
164-
165-
To use MemOS with [Ollama](https://ollama.com/), first install the Ollama CLI:
166-
167-
```bash
168-
curl -fsSL https://ollama.com/install.sh | sh
169-
```
170-
171-
#### Transformers Support
172-
173-
To use functionalities based on the `transformers` library, ensure you have [PyTorch](https://pytorch.org/get-started/locally/) installed (CUDA version recommended for GPU acceleration).
174-
175-
#### Download Examples
135+
## 🚀 Quickstart Guide
176136

177-
To download example code, data and configurations, run the following command:
137+
### Get API Key
138+
- Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing)
139+
- Open the API Keys Console in the MemOS dashboard and copy the API Key into the initialization code
178140

179-
```bash
180-
memos download_examples
181-
```
182-
183-
## 🚀 Getting Started
184-
185-
### ⭐️ MemOS online API
186-
The easiest way to use MemOS. Equip your agent with memory **in minutes**!
187-
188-
Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing).
189-
190-
191-
### Self-Hosted Server
192-
1. Get the repository.
193-
```bash
194-
git clone https://github.com/MemTensor/MemOS.git
195-
cd MemOS
196-
pip install -r ./docker/requirements.txt
197-
```
141+
### Install via pip
198142

199-
2. Configure `docker/.env.example` and copy to `MemOS/.env`
200-
3. Start the service.
201143
```bash
202-
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 8
144+
pip install MemoryOS -U
203145
```
204146

205-
### Interface SDK
206-
#### Here is a quick example showing how to create interface SDK
147+
### Basic Usage
207148

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.
149+
- Initialize MemOS client with API Key to start sending requests
209150
```python
210151
# Please make sure MemoS is installed (pip install MemoryOS -U)
211152
from memos.api.client import MemOSClient
212153

213154
# Initialize the client using the API Key
214155
client = MemOSClient(api_key="YOUR_API_KEY")
156+
```
215157

158+
- This API allows you to add one or more messages to a specific conversation. As illustrated in the examples bellow, you can add messages in real time during a user-assistant interaction, import historical messages in bulk, or enrich the conversation with user preferences and behavior data. All added messages are transformed into memories by MemOS, enabling their retrieval in future conversations to support chat history management, user behavior tracking, and personalized interactions.
159+
```python
216160
messages = [
217161
{"role": "user", "content": "I have planned to travel to Guangzhou during the summer vacation. What chain hotels are available for accommodation?"},
218162
{"role": "assistant", "content": "You can consider [7 Days, All Seasons, Hilton], and so on."},
@@ -226,79 +170,89 @@ res = client.add_message(messages=messages, user_id=user_id, conversation_id=con
226170
print(f"result: {res}")
227171
```
228172

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'.
173+
- This API allows you to query a user’s memory and returns the fragments most relevant to the input. These can serve as references for the model when generating responses. As shown in the examples bellow, You can retrieve memory in real time during a user’s conversation with the AI, or perform a global search across their entire memory to create user profiles or support personalized recommendations, improving both dialogue coherence and personalization.
174+
In the latest update, in addition to “Fact Memory”, the system now supports “Preference Memory”, enabling LLM to respond in a way that better understands the user.
230175
```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-
237176
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?"
238177
user_id = "memos_user_123"
239-
conversation_id = "0928"
178+
conversation_id = "0610"
240179
res = client.search_memory(query=query, user_id=user_id, conversation_id=conversation_id)
241180

242181
print(f"result: {res}")
243182
```
244183

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)
248-
from memos.api.client import MemOSClient
249-
250-
# Initialize the client using the API Key
251-
client = MemOSClient(api_key="YOUR_API_KEY")
252-
253-
user_ids = ["memos_user_123"]
254-
# Replace with the memory ID
255-
memory_ids = ["6b23b583-f4c4-4a8f-b345-58d0c48fea04"]
256-
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."
272-
# Replace with the knowledgebase ID
273-
allow_knowledgebase_ids = ["basee5ec9050-c964-484f-abf1-ce3e8e2aa5b7"]
274-
275-
res = client.add_feedback(
276-
user_id=user_id,
277-
conversation_id=conversation_id,
278-
feedback_content=feedback_content,
279-
allow_knowledgebase_ids=allow_knowledgebase_ids
280-
)
281-
282-
print(f"result: {res}")
283-
```
284-
285-
This interface is used to create a knowledgebase associated with a project
286-
```python
287-
# Please make sure MemoS is installed (pip install MemoryOS -U)
288-
from memos.api.client import MemOSClient
289-
290-
# Initialize the client using the API Key
291-
client = MemOSClient(api_key="YOUR_API_KEY")
292-
293-
knowledgebase_name = "Financial Reimbursement Knowledge Base"
294-
knowledgebase_description = "A compilation of all knowledge related to the company's financial reimbursements."
184+
### Self-Hosted Server
185+
1. Get the repository.
186+
```bash
187+
git clone https://github.com/MemTensor/MemOS.git
188+
cd MemOS
189+
pip install -r ./docker/requirements.txt
190+
```
191+
2. Configure `docker/.env.example` and copy to `MemOS/.env`
192+
- The `OPENAI_API_KEY`,`MOS_EMBEDDER_API_KEY`,`MEMRADER_API_KEY` and others can be applied for through [`BaiLian`](https://bailian.console.aliyun.com/?spm=a2c4g.11186623.0.0.2f2165b08fRk4l&tab=api#/api).
193+
- Fill in the corresponding configuration in the `MemOS/.env` file.
194+
3. Start the service.
295195

296-
res = client.create_knowledgebase(
297-
knowledgebase_name=knowledgebase_name,
298-
knowledgebase_description=knowledgebase_description
299-
)
300-
print(f"result: {res}")
301-
```
196+
- Launch via Docker
197+
###### Tips: Please ensure that Docker Compose is installed successfully and that you have navigated to the docker directory (via `cd docker`) before executing the following command.
198+
```bash
199+
# Enter docker directory
200+
docker compose up
201+
```
202+
##### If you prefer to deploy using Docker, please refer to the [`Docker Reference`](https://docs.openmem.net/open_source/getting_started/rest_api_server/#method-1-docker-use-repository-dependency-package-imagestart-recommended-use).
203+
204+
- Launch via the uvicorn command line interface (CLI)
205+
###### Tips: Please ensure that Neo4j and Qdrant are running before executing the following command.
206+
```bash
207+
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 1
208+
```
209+
##### For detailed integration steps, see the [`CLI Reference`](https://docs.openmem.net/open_source/getting_started/rest_api_server/#method-3client-install-with-CLI).
210+
211+
212+
213+
Example
214+
- Add User Message
215+
```python
216+
import requests
217+
import json
218+
219+
data = {
220+
"user_id": "8736b16e-1d20-4163-980b-a5063c3facdc",
221+
"mem_cube_id": "b32d0977-435d-4828-a86f-4f47f8b55bca",
222+
"messages": [
223+
{
224+
"role": "user",
225+
"content": "I like strawberry"
226+
}
227+
],
228+
"async_mode": "sync"
229+
}
230+
headers = {
231+
"Content-Type": "application/json"
232+
}
233+
url = "http://localhost:8000/product/add"
234+
235+
res = requests.post(url=url, headers=headers, data=json.dumps(data))
236+
print(f"result: {res.json()}")
237+
```
238+
- Search User Memory
239+
```python
240+
import requests
241+
import json
242+
243+
data = {
244+
"query": "What do I like",
245+
"user_id": "8736b16e-1d20-4163-980b-a5063c3facdc",
246+
"mem_cube_id": "b32d0977-435d-4828-a86f-4f47f8b55bca"
247+
}
248+
headers = {
249+
"Content-Type": "application/json"
250+
}
251+
url = "http://localhost:8000/product/search"
252+
253+
res = requests.post(url=url, headers=headers, data=json.dumps(data))
254+
print(f"result: {res.json()}")
255+
```
302256

303257
## 💬 Community & Support
304258

src/memos/api/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def init(cls) -> None:
201201
sk = os.getenv("SK")
202202

203203
if not (server_addr and data_id and ak and sk):
204-
logger.warning("missing NACOS_SERVER_ADDR / AK / SK / DATA_ID")
204+
logger.warning("missing NACOS_SERVER_ADDR / AK / SK / DATA_ID")
205205
return
206206

207207
base_url = f"http://{server_addr}/nacos/v1/cs/configs"

0 commit comments

Comments
 (0)