From 73616400f2440887f2d8babc4d1bd0f565146bf1 Mon Sep 17 00:00:00 2001 From: Hao <120852460@qq.com> Date: Wed, 5 Nov 2025 17:17:38 +0800 Subject: [PATCH 1/5] doc: Update readme --- README.md | 23 ++++++++- evaluation/.env-example | 23 --------- evaluation/README.md | 5 +- .../configs-example/mem_cube_config.json | 51 ------------------- .../configs-example/mos_memos_config.json | 51 ------------------- src/memos/log.py | 2 +- 6 files changed, 24 insertions(+), 131 deletions(-) delete mode 100644 evaluation/configs-example/mem_cube_config.json delete mode 100644 evaluation/configs-example/mos_memos_config.json diff --git a/README.md b/README.md index a08177676..30f01f49c 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,27 @@ showcasing its capabilities in **information extraction**, **temporal and cross- ## 🚀 Getting Started +### ⭐️ MemOS online API +The easiest way to use MemOS. Equip your agent with memory **in minutes**! + +Sign up and get started on[`MemOS dashboard`](https://memos-dashboard.openmem.net/cn/quickstart/?source=landing). + + +### Self-Hosted Server +1. Get the repository. +```bash +git clone https://github.com/MemTensor/MemOS.git +cd MemOS +pip install -r ./docker/requirements.txt +``` + +2. Configure `docker/.env.example` and copy to `MemOS/.env` +3. Start the service. +```bash +uvicorn memos.api.server_api:app --host 0.0.0.0 --port 8001 --workers 8 +``` + +### Local SDK Here's a quick example of how to create a **`MemCube`**, load it from a directory, access its memories, and save it. ```python @@ -102,7 +123,7 @@ for item in mem_cube.act_mem.get_all(): mem_cube.dump("tmp/mem_cube") ``` -What about **`MOS`** (Memory Operating System)? It's 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: +**`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: ```python from memos.configs.mem_os import MOSConfig diff --git a/evaluation/.env-example b/evaluation/.env-example index 0e94e9caa..5381532c2 100644 --- a/evaluation/.env-example +++ b/evaluation/.env-example @@ -22,26 +22,3 @@ SUPERMEMORY_API_KEY="sm_xxx" MEMOBASE_API_KEY="xxx" MEMOBASE_PROJECT_URL="http://***.***.***.***:8019" -# eval settings -PRE_SPLIT_CHUNK=false - -# Configuration Only For Scheduler -# RabbitMQ Configuration -MEMSCHEDULER_RABBITMQ_HOST_NAME=rabbitmq-cn-***.cn-***.amqp-32.net.mq.amqp.aliyuncs.com -MEMSCHEDULER_RABBITMQ_USER_NAME=*** -MEMSCHEDULER_RABBITMQ_PASSWORD=*** -MEMSCHEDULER_RABBITMQ_VIRTUAL_HOST=memos -MEMSCHEDULER_RABBITMQ_ERASE_ON_CONNECT=true -MEMSCHEDULER_RABBITMQ_PORT=5672 - -# OpenAI Configuration -MEMSCHEDULER_OPENAI_API_KEY=sk-*** -MEMSCHEDULER_OPENAI_BASE_URL=http://***.***.***.***:3000/v1 -MEMSCHEDULER_OPENAI_DEFAULT_MODEL=gpt-4o-mini - -# Graph DB Configuration -MEMSCHEDULER_GRAPHDBAUTH_URI=bolt://localhost:7687 -MEMSCHEDULER_GRAPHDBAUTH_USER=neo4j -MEMSCHEDULER_GRAPHDBAUTH_PASSWORD=*** -MEMSCHEDULER_GRAPHDBAUTH_DB_NAME=neo4j -MEMSCHEDULER_GRAPHDBAUTH_AUTO_CREATE=true diff --git a/evaluation/README.md b/evaluation/README.md index 8683c60b2..a5a4f32ca 100644 --- a/evaluation/README.md +++ b/evaluation/README.md @@ -16,10 +16,7 @@ This repository provides tools and scripts for evaluating the `LoCoMo`, `LongMem ``` ## Configuration - -1. Copy the `.env-example` file to `.env`, and fill in the required environment variables according to your environment and API keys. - -2. Copy the `configs-example/` directory to a new directory named `configs/`, and modify the configuration files inside it as needed. This directory contains model and API-specific settings. +Copy the `.env-example` file to `.env`, and fill in the required environment variables according to your environment and API keys. ## Setup MemOS ### local server diff --git a/evaluation/configs-example/mem_cube_config.json b/evaluation/configs-example/mem_cube_config.json deleted file mode 100644 index d609d27b0..000000000 --- a/evaluation/configs-example/mem_cube_config.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "user_id": "__USER_ID__", - "cube_id": "__USER_ID__", - "text_mem": { - "backend": "tree_text", - "config": { - "extractor_llm": { - "backend": "openai", - "config": { - "model_name_or_path": "gpt-4o-mini", - "temperature": 0.8, - "max_tokens": 1024, - "top_p": 0.9, - "top_k": 50, - "api_key": "sk-***REDACTED***", - "api_base": "http://***.***.***.***:3000/v1" - } - }, - "dispatcher_llm": { - "backend": "openai", - "config": { - "model_name_or_path": "gpt-4o-mini", - "temperature": 0.8, - "max_tokens": 1024, - "top_p": 0.9, - "top_k": 50, - "api_key": "sk-***REDACTED***", - "api_base": "http://***.***.***.***:3000/v1" - } - }, - "graph_db": { - "backend": "neo4j", - "config": { - "uri": "bolt://***.***.***.***:7687", - "user": "***REDACTED***", - "password": "***REDACTED***", - "db_name": "__DB_NAME__", - "auto_create": true - } - }, - "embedder": { - "backend": "ollama", - "config": { - "model_name_or_path": "nomic-embed-text:latest" - } - } - } - }, - "act_mem": {}, - "para_mem": {} -} diff --git a/evaluation/configs-example/mos_memos_config.json b/evaluation/configs-example/mos_memos_config.json deleted file mode 100644 index b7f2767b7..000000000 --- a/evaluation/configs-example/mos_memos_config.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "user_id": "root", - "chat_model": { - "backend": "openai", - "config": { - "model_name_or_path": "gpt-4o-mini", - "api_key": "sk-***REDACTED***", - "api_base": "http://***.***.***.***:3000/v1", - "temperature": 0.1, - "remove_think_prefix": true, - "max_tokens": 4096 - } - }, - "mem_reader": { - "backend": "simple_struct", - "config": { - "llm": { - "backend": "openai", - "config": { - "model_name_or_path": "gpt-4o-mini", - "temperature": 0.8, - "max_tokens": 1024, - "top_p": 0.9, - "top_k": 50, - "api_key": "sk-***REDACTED***", - "api_base": "http://***.***.***.***:3000/v1" - } - }, - "embedder": { - "backend": "ollama", - "config": { - "model_name_or_path": "nomic-embed-text:latest" - } - }, - "chunker": { - "backend": "sentence", - "config": { - "tokenizer_or_token_counter": "gpt2", - "chunk_size": 512, - "chunk_overlap": 128, - "min_sentences_per_chunk": 1 - } - } - } - }, - "max_turns_window": 30, - "top_k": "__TOP_K__", - "enable_textual_memory": true, - "enable_activation_memory": false, - "enable_parametric_memory": false -} diff --git a/src/memos/log.py b/src/memos/log.py index 2a538fdde..faa808414 100644 --- a/src/memos/log.py +++ b/src/memos/log.py @@ -187,7 +187,7 @@ def close(self): }, "handlers": { "console": { - "level": "DEBUG", + "level": selected_log_level, "class": "logging.StreamHandler", "stream": stdout, "formatter": "no_datetime", From 067f8957ea0ef4bebf7cc3534881606efd212a4b Mon Sep 17 00:00:00 2001 From: Hao <120852460@qq.com> Date: Wed, 5 Nov 2025 20:59:10 +0800 Subject: [PATCH 2/5] feat(env): update .env.example --- docker/.env.example | 70 +++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/docker/.env.example b/docker/.env.example index 33f7ae853..b58920f3c 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -1,29 +1,61 @@ # MemOS Environment Variables Configuration +TZ=Asia/Shanghai -# Path to memory storage (e.g. /tmp/data_test) -MOS_CUBE_PATH= + +MOS_CUBE_PATH=/tmp/data_test # Path to memory storage (e.g. /tmp/data_test) +MOS_ENABLE_DEFAULT_CUBE_CONFIG=true # Enable default cube config (true/false) # OpenAI Configuration -OPENAI_API_KEY= # Your OpenAI API key -OPENAI_API_BASE= # OpenAI API base URL (default: https://api.openai.com/v1) +OPENAI_API_KEY=sk-xxx +OPENAI_API_BASE=http://xxx + +# MemOS Chat Model Configuration +MOS_CHAT_MODEL=gpt-4o-mini +MOS_CHAT_TEMPERATURE=0.8 +MOS_MAX_TOKENS=8000 +MOS_TOP_P=0.9 +MOS_TOP_K=50 +MOS_CHAT_MODEL_PROVIDER=openai -# MemOS Feature Toggles -MOS_ENABLE_DEFAULT_CUBE_CONFIG= # Enable default cube config (true/false) -MOS_ENABLE_SCHEDULER= # Enable background scheduler (true/false) +# graph db +# neo4j +NEO4J_BACKEND=xxx +NEO4J_URI=bolt://xxx +NEO4J_USER=xxx +NEO4J_PASSWORD=xxx +MOS_NEO4J_SHARED_DB=xxx +NEO4J_DB_NAME=xxx -# Neo4j Configuration -NEO4J_URI= # Neo4j connection URI (e.g. bolt://localhost:7687) -NEO4J_USER= # Neo4j username -NEO4J_PASSWORD= # Neo4j password -MOS_NEO4J_SHARED_DB= # Shared Neo4j database name (if using multi-db) +# tetxmem reog +MOS_ENABLE_REORGANIZE=false # MemOS User Configuration -MOS_USER_ID= # Unique user ID -MOS_SESSION_ID= # Session ID for current chat -MOS_MAX_TURNS_WINDOW= # Max number of turns to keep in memory +MOS_USER_ID=root +MOS_SESSION_ID=default_session +MOS_MAX_TURNS_WINDOW=20 + +# MemRader Configuration +MEMRADER_MODEL=gpt-4o-mini +MEMRADER_API_KEY=sk-xxx +MEMRADER_API_BASE=http://xxx:3000/v1 +MEMRADER_MAX_TOKENS=5000 + +#embedding & rerank +EMBEDDING_DIMENSION=1024 +MOS_EMBEDDER_BACKEND=universal_api +MOS_EMBEDDER_MODEL=bge-m3 +MOS_EMBEDDER_API_BASE=http://xxx +MOS_EMBEDDER_API_KEY=EMPTY +MOS_RERANKER_BACKEND=http_bge +MOS_RERANKER_URL=http://xxx +# Ollama Configuration (for embeddings) +#OLLAMA_API_BASE=http://xxx -# Ollama Configuration (for local embedding models) -OLLAMA_API_BASE= # Ollama API base URL (e.g. http://localhost:11434) +# milvus for pref mem +MILVUS_URI=http://xxx +MILVUS_USER_NAME=xxx +MILVUS_PASSWORD=xxx -# Embedding Configuration -MOS_EMBEDDER_BACKEND= # Embedding backend: openai, ollama, etc. +# pref mem +ENABLE_PREFERENCE_MEMORY=true +RETURN_ORIGINAL_PREF_MEM=true From 8d909d4a201ad1cee1613d655c7b5284a4943a70 Mon Sep 17 00:00:00 2001 From: Hao <120852460@qq.com> Date: Wed, 5 Nov 2025 21:15:35 +0800 Subject: [PATCH 3/5] refactor(client): pref mem --- evaluation/scripts/utils/client.py | 42 ++++++++++++------------------ 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/evaluation/scripts/utils/client.py b/evaluation/scripts/utils/client.py index 9aa527903..bb79ce20b 100644 --- a/evaluation/scripts/utils/client.py +++ b/evaluation/scripts/utils/client.py @@ -250,33 +250,23 @@ def search(self, query, user_id, top_k): preference_note = json.loads(response.text)["data"]["preference_note"] for i in text_mem_res: i.update({"memory": i.pop("memory_value")}) + explicit_pref_string = "Explicit Preference:" + implicit_pref_string = "\n\nImplicit Preference:" + explicit_idx = 0 + implicit_idx = 0 + for pref in pref_mem_res: + if pref["preference_type"] == "explicit_preference": + explicit_pref_string += f"\n{explicit_idx + 1}. {pref['preference']}" + explicit_idx += 1 + if pref["preference_type"] == "explicit_preference": + implicit_pref_string += f"\n{implicit_idx + 1}. {pref['preference']}" + implicit_idx += 1 + + return { + "text_mem": [{"memories": text_mem_res}], + "pref_string": explicit_pref_string + implicit_pref_string + preference_note, + } - explicit_prefs = [ - p["preference"] - for p in pref_mem_res - if p.get("preference_type", "") == "explicit_preference" - ] - implicit_prefs = [ - p["preference"] - for p in pref_mem_res - if p.get("preference_type", "") == "implicit_preference" - ] - - pref_parts = [] - if explicit_prefs: - pref_parts.append( - "Explicit Preference:\n" - + "\n".join(f"{i + 1}. {p}" for i, p in enumerate(explicit_prefs)) - ) - if implicit_prefs: - pref_parts.append( - "Implicit Preference:\n" - + "\n".join(f"{i + 1}. {p}" for i, p in enumerate(implicit_prefs)) - ) - - pref_string = "\n".join(pref_parts) + preference_note - - return {"text_mem": [{"memories": text_mem_res}], "pref_string": pref_string} except Exception as e: if attempt < max_retries - 1: time.sleep(2**attempt) From 5ce4f999c61cb23c82efe19a0df4ad52c0479cf3 Mon Sep 17 00:00:00 2001 From: Hao <120852460@qq.com> Date: Thu, 6 Nov 2025 11:21:06 +0800 Subject: [PATCH 4/5] fix pref type --- evaluation/scripts/utils/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/evaluation/scripts/utils/client.py b/evaluation/scripts/utils/client.py index bb79ce20b..157c3f8ea 100644 --- a/evaluation/scripts/utils/client.py +++ b/evaluation/scripts/utils/client.py @@ -258,7 +258,7 @@ def search(self, query, user_id, top_k): if pref["preference_type"] == "explicit_preference": explicit_pref_string += f"\n{explicit_idx + 1}. {pref['preference']}" explicit_idx += 1 - if pref["preference_type"] == "explicit_preference": + if pref["preference_type"] == "implicit_preference": implicit_pref_string += f"\n{implicit_idx + 1}. {pref['preference']}" implicit_idx += 1 From e85109bc118d96d498114bf8cbb9429817df04d9 Mon Sep 17 00:00:00 2001 From: Hao <120852460@qq.com> Date: Thu, 6 Nov 2025 11:42:15 +0800 Subject: [PATCH 5/5] =?UTF-8?q?chore(env):=20=E6=9B=B4=E6=96=B0=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=8F=98=E9=87=8F=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/.env.example | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docker/.env.example b/docker/.env.example index b58920f3c..0f4fcb65d 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -1,13 +1,12 @@ # MemOS Environment Variables Configuration TZ=Asia/Shanghai - -MOS_CUBE_PATH=/tmp/data_test # Path to memory storage (e.g. /tmp/data_test) -MOS_ENABLE_DEFAULT_CUBE_CONFIG=true # Enable default cube config (true/false) +MOS_CUBE_PATH="/tmp/data_test" # Path to memory storage (e.g. /tmp/data_test) +MOS_ENABLE_DEFAULT_CUBE_CONFIG="true" # Enable default cube config (true/false) # OpenAI Configuration -OPENAI_API_KEY=sk-xxx -OPENAI_API_BASE=http://xxx +OPENAI_API_KEY="sk-xxx" # Your OpenAI API key +OPENAI_API_BASE="http://xxx" # OpenAI API base URL (default: https://api.openai.com/v1) # MemOS Chat Model Configuration MOS_CHAT_MODEL=gpt-4o-mini