Skip to content

Commit bbca35f

Browse files
CaralHsitangg555zZhangSirpursuesfridayL
authored
feat: Merge from main (some hot-fix) (#832)
* fix: fix bugs when running local queue for memos * fix: remove an unnecessary function * fix: update README.md * update requirement,Dockerfile * fix: update README.md * fix: update README.md * feat: update readme * feat: fix NACOS * feat: add timer log * update requirements * fix: 12.26 update README.md * change local server name * update docker-compose.yml * fix: issues caused by no reading default use_redis from env * feat: fix requirements * add neo4j * fix: logs context and empty embedding * fix reranker * fix: conflict --------- Co-authored-by: chentang <travistang@foxmail.com> Co-authored-by: Elvis <1693372324@qq.com> Co-authored-by: pursues <15180521816@163.com> Co-authored-by: chunyu li <78344051+fridayL@users.noreply.github.com> Co-authored-by: liji <532311301@qq.com> Co-authored-by: harvey_xiang <harvey_xiang22@163.com> Co-authored-by: lijicode <34564964+lijicode@users.noreply.github.com> Co-authored-by: Zehao Lin <glin1993@outlook.com> Co-authored-by: fridayL <lcy081099@gmail.com>
1 parent d632dde commit bbca35f

12 files changed

Lines changed: 252 additions & 229 deletions

File tree

README.md

Lines changed: 85 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -118,89 +118,31 @@ showcasing its capabilities in **information extraction**, **temporal and cross-
118118
- **🔌 Extensible**: Easily extend and customize memory modules, data sources, and LLM integrations.
119119

120120

121-
## 📦 Installation
121+
## 🚀 Quickstart Guide
122122

123-
### Install via pip
124-
125-
```bash
126-
pip install MemoryOS
127-
```
128-
129-
### Optional Dependencies
130-
131-
MemOS provides several optional dependency groups for different features. You can install them based on your needs.
132-
133-
| Feature | Package Name |
134-
| --------------------- | ------------------------- |
135-
| Tree Memory | `MemoryOS[tree-mem]` |
136-
| Memory Reader | `MemoryOS[mem-reader]` |
137-
| Memory Scheduler | `MemoryOS[mem-scheduler]` |
138-
139-
Example installation commands:
140-
141-
```bash
142-
pip install MemoryOS[tree-mem]
143-
pip install MemoryOS[tree-mem,mem-reader]
144-
pip install MemoryOS[mem-scheduler]
145-
pip install MemoryOS[tree-mem,mem-reader,mem-scheduler]
146-
```
147-
148-
### External Dependencies
149-
150-
#### Ollama Support
151-
152-
To use MemOS with [Ollama](https://ollama.com/), first install the Ollama CLI:
153-
154-
```bash
155-
curl -fsSL https://ollama.com/install.sh | sh
156-
```
157-
158-
#### Transformers Support
159-
160-
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).
161-
162-
#### Download Examples
123+
### Get API Key
124+
- Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing)
125+
- Open the API Keys Console in the MemOS dashboard and copy the API Key into the initialization code
163126

164-
To download example code, data and configurations, run the following command:
165-
166-
```bash
167-
memos download_examples
168-
```
169-
170-
171-
## 🚀 Getting Started
172-
173-
### ⭐️ MemOS online API
174-
The easiest way to use MemOS. Equip your agent with memory **in minutes**!
175-
176-
Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing).
177-
178-
179-
### Self-Hosted Server
180-
1. Get the repository.
181-
```bash
182-
git clone https://github.com/MemTensor/MemOS.git
183-
cd MemOS
184-
pip install -r ./docker/requirements.txt
185-
```
127+
### Install via pip
186128

187-
2. Configure `docker/.env.example` and copy to `MemOS/.env`
188-
3. Start the service.
189129
```bash
190-
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 8
130+
pip install MemoryOS -U
191131
```
192132

193-
### Interface SDK
194-
#### Here is a quick example showing how to create all interface SDK
133+
### Basic Usage
195134

196-
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.
135+
- Initialize MemOS client with API Key to start sending requests
197136
```python
198137
# Please make sure MemoS is installed (pip install MemoryOS -U)
199138
from memos.api.client import MemOSClient
200139

201140
# Initialize the client using the API Key
202141
client = MemOSClient(api_key="YOUR_API_KEY")
142+
```
203143

144+
- 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.
145+
```python
204146
messages = [
205147
{"role": "user", "content": "I have planned to travel to Guangzhou during the summer vacation. What chain hotels are available for accommodation?"},
206148
{"role": "assistant", "content": "You can consider [7 Days, All Seasons, Hilton], and so on."},
@@ -214,79 +156,90 @@ res = client.add_message(messages=messages, user_id=user_id, conversation_id=con
214156
print(f"result: {res}")
215157
```
216158

217-
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'.
159+
- 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.
160+
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.
218161
```python
219-
# Please make sure MemoS is installed (pip install MemoryOS -U)
220-
from memos.api.client import MemOSClient
221-
222-
# Initialize the client using the API Key
223-
client = MemOSClient(api_key="YOUR_API_KEY")
224-
225162
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?"
226163
user_id = "memos_user_123"
227-
conversation_id = "0928"
164+
conversation_id = "0610"
228165
res = client.search_memory(query=query, user_id=user_id, conversation_id=conversation_id)
229166

230167
print(f"result: {res}")
231168
```
232169

233-
This interface is used to delete the memory of specified users and supports batch deletion.
234-
```python
235-
# Please make sure MemoS is installed (pip install MemoryOS -U)
236-
from memos.api.client import MemOSClient
237-
238-
# Initialize the client using the API Key
239-
client = MemOSClient(api_key="YOUR_API_KEY")
240-
241-
user_ids = ["memos_user_123"]
242-
# Replace with the memory ID
243-
memory_ids = ["6b23b583-f4c4-4a8f-b345-58d0c48fea04"]
244-
res = client.delete_memory(user_ids=user_ids, memory_ids=memory_ids)
245-
246-
print(f"result: {res}")
247-
```
248-
249-
This interface is used to add feedback to messages in the current session, allowing MemOS to correct its memory based on user feedback.
250-
```python
251-
# Please make sure MemoS is installed (pip install MemoryOS -U)
252-
from memos.api.client import MemOSClient
253-
254-
# Initialize the client using the API Key
255-
client = MemOSClient(api_key="YOUR_API_KEY")
256-
257-
user_id = "memos_user_123"
258-
conversation_id = "memos_feedback_conv"
259-
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."
260-
# Replace with the knowledgebase ID
261-
allow_knowledgebase_ids = ["basee5ec9050-c964-484f-abf1-ce3e8e2aa5b7"]
262-
263-
res = client.add_feedback(
264-
user_id=user_id,
265-
conversation_id=conversation_id,
266-
feedback_content=feedback_content,
267-
allow_knowledgebase_ids=allow_knowledgebase_ids
268-
)
269-
270-
print(f"result: {res}")
271-
```
272-
273-
This interface is used to create a knowledgebase associated with a project
274-
```python
275-
# Please make sure MemoS is installed (pip install MemoryOS -U)
276-
from memos.api.client import MemOSClient
277-
278-
# Initialize the client using the API Key
279-
client = MemOSClient(api_key="YOUR_API_KEY")
280170

281-
knowledgebase_name = "Financial Reimbursement Knowledge Base"
282-
knowledgebase_description = "A compilation of all knowledge related to the company's financial reimbursements."
171+
### Self-Hosted Server
172+
1. Get the repository.
173+
```bash
174+
git clone https://github.com/MemTensor/MemOS.git
175+
cd MemOS
176+
pip install -r ./docker/requirements.txt
177+
```
178+
2. Configure `docker/.env.example` and copy to `MemOS/.env`
179+
- 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).
180+
- Fill in the corresponding configuration in the `MemOS/.env` file.
181+
3. Start the service.
283182

284-
res = client.create_knowledgebase(
285-
knowledgebase_name=knowledgebase_name,
286-
knowledgebase_description=knowledgebase_description
287-
)
288-
print(f"result: {res}")
289-
```
183+
- Launch via Docker
184+
###### 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.
185+
```bash
186+
# Enter docker directory
187+
docker compose up
188+
```
189+
##### 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).
190+
191+
- Launch via the uvicorn command line interface (CLI)
192+
###### Tips: Please ensure that Neo4j and Qdrant are running before executing the following command.
193+
```bash
194+
uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 1
195+
```
196+
##### For detailed integration steps, see the [`CLI Reference`](https://docs.openmem.net/open_source/getting_started/rest_api_server/#method-3client-install-with-CLI).
197+
198+
199+
200+
Example
201+
- Add User Message
202+
```python
203+
import requests
204+
import json
205+
206+
data = {
207+
"user_id": "8736b16e-1d20-4163-980b-a5063c3facdc",
208+
"mem_cube_id": "b32d0977-435d-4828-a86f-4f47f8b55bca",
209+
"messages": [
210+
{
211+
"role": "user",
212+
"content": "I like strawberry"
213+
}
214+
],
215+
"async_mode": "sync"
216+
}
217+
headers = {
218+
"Content-Type": "application/json"
219+
}
220+
url = "http://localhost:8000/product/add"
221+
222+
res = requests.post(url=url, headers=headers, data=json.dumps(data))
223+
print(f"result: {res.json()}")
224+
```
225+
- Search User Memory
226+
```python
227+
import requests
228+
import json
229+
230+
data = {
231+
"query": "What do I like",
232+
"user_id": "8736b16e-1d20-4163-980b-a5063c3facdc",
233+
"mem_cube_id": "b32d0977-435d-4828-a86f-4f47f8b55bca"
234+
}
235+
headers = {
236+
"Content-Type": "application/json"
237+
}
238+
url = "http://localhost:8000/product/search"
239+
240+
res = requests.post(url=url, headers=headers, data=json.dumps(data))
241+
print(f"result: {res.json()}")
242+
```
290243

291244
## 💬 Community & Support
292245

0 commit comments

Comments
 (0)