memU
memU copied to clipboard
Using a self-deployed service, how to obtain the api_key
cat .env
MEMU_LLM_PROVIDER=deepseek
DEEPSEEK_API_KEY=sk-thekey***
DEEPSEEK_BASE_URL=https://api.deepseek.com
DEEPSEEK_API_VERSION=2024-05-01-preview
MEMU_DEEPSEEK_MODEL=deepseek-chat
docker-compose -f compose/docker-compose.server-cpu.yml up -d
I don't know where the api_key comes from, so I casually passed the value of the api_key parameter and got an error
cat test.py
from memu import MemuClient
# 连接到你的本地服务
memu_client = MemuClient(
base_url="http://127.0.0.1:8000", # 使用本地地址
api_key='helloworld9iiiii'
)
# 测试记忆功能
memu_client.memorize_conversation(
conversation="用户:我叫小明,喜欢打篮球\nAI:很高兴认识你!",
user_id="user001",
user_name="小明",
agent_id="assistant001",
agent_name="AI助手"
)
python test.py
2025-09-22 11:49:41 | memu.sdk.python.client:98 | INFO | MemU SDK client initialized with base_url: http://127.0.0.1:8000/
2025-09-22 11:49:41 | memu.sdk.python.client:251 | INFO | Starting memorization for user user001 and agent assistant001
2025-09-22 11:49:41 | memu.sdk.python.client:264 | INFO | Memorization task started: c737a5b3-2dfd-42da-9dd1-681ca7c044e5
docker logs -f 8a --tail 111
🚀 Starting MemU Server in Docker...
======================================
📊 Server Configuration:
Host: 0.0.0.0
Port: 8000
Debug: false
Memory Dir: /app/memory
LLM Provider: deepseek
Embeddings: true
✅ Configuration validated
🌐 Server will be available at:
API: http://localhost:8000
Docs: http://localhost:8000/docs
Health: http://localhost:8000/health
📝 Press Ctrl+C to stop the server
🚀 Starting MemU Server...
Host: 0.0.0.0
Port: 8000
Debug: False
Memory Dir: memu/server/memory
LLM Provider: deepseek
Embeddings: True
INFO: Started server process [1]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
2025-09-22 03:49:41 | memu.server.middleware:26 | INFO | Request: POST /api/v1/memory/memorize - Client: 172.22.0.1
2025-09-22 03:49:41 | memu.server.services.memory_service:48 | INFO | Memory service initialized with directory: memu/server/memory
2025-09-22 03:49:41 | memu.server.routers.memory:67 | INFO | Starting memorization for user user001, agent assistant001
2025-09-22 03:49:41 | memu.server.services.task_service:53 | INFO | Created task c737a5b3-2dfd-42da-9dd1-681ca7c044e5 of type memorize
2025-09-22 03:49:41 | memu.server.middleware:38 | INFO | Response: 200 - Time: 0.002s - Path: /api/v1/memory/memorize
INFO: 172.22.0.1:50788 - "POST /api/v1/memory/memorize HTTP/1.1" 200 OK
2025-09-22 03:49:41 | memu.server.routers.memory:119 | INFO | Processing memorization task c737a5b3-2dfd-42da-9dd1-681ca7c044e5
2025-09-22 03:49:41 | memu.server.services.task_service:102 | INFO | Updated task c737a5b3-2dfd-42da-9dd1-681ca7c044e5 to status PROCESSING
2025-09-22 03:49:41 | memu.memory.file_manager:53 | INFO | MemoryFileManager initialized with directory: memu/server/memory
2025-09-22 03:49:41 | memu.memory.embeddings:455 | INFO | Embedding provider: deepseek
2025-09-22 03:49:41 | memu.memory.embeddings:456 | INFO | Embedding model: text-embedding-3-small
2025-09-22 03:49:41 | memu.memory.embeddings:457 | INFO | Embedding model type: sentence_transformers
2025-09-22 03:49:41 | memu.memory.embeddings:458 | INFO | Embedding device: cpu
2025-09-22 03:49:41 | memu.memory.embeddings:491 | WARNING | No embedding client configuration found in environment variables
2025-09-22 03:49:41 | memu.memory.memory_agent:63 | INFO | Embeddings enabled for semantic retrieval
2025-09-22 03:49:41 | memu.memory.memory_agent:78 | INFO | Memory Core initialized: 2 memory types, embeddings: True
2025-09-22 03:49:41 | memu.memory.memory_agent:124 | INFO | Memory Agent initialized: 6 actions available
2025-09-22 03:49:41 | memu.server.services.memory_service:158 | INFO | Using directory structure: None/assistant001/user001/ for character: 小明
2025-09-22 03:49:41 | memu.memory.memory_agent:184 | INFO | 🚀 Starting iterative conversation processing for 小明
2025-09-22 03:49:41 | memu.memory.memory_agent:246 | INFO | 🔄 Iteration 1/20
2025-09-22 03:49:46 | memu.memory.memory_agent:297 | INFO | 🔧 Calling function: add_activity_memory
2025-09-22 03:49:51 | memu.memory.actions.add_activity_memory:300 | WARNING | Failed to generate embedding for memory item d9f7c7: Traceback (most recent call last):
File "/app/memu/memory/actions/add_activity_memory.py", line 274, in _add_memory_item_embedding
embedding_vector = self.embedding_client.embed(item["content"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'embed'
2025-09-22 03:49:51 | memu.memory.memory_agent:306 | INFO | Function time used: 4.98 seconds
2025-09-22 03:49:51 | memu.memory.memory_agent:246 | INFO | 🔄 Iteration 2/20
2025-09-22 03:49:59 | memu.memory.memory_agent:297 | INFO | 🔧 Calling function: run_theory_of_mind
2025-09-22 03:50:10 | memu.memory.memory_agent:306 | INFO | Function time used: 11.64 seconds
2025-09-22 03:50:10 | memu.memory.memory_agent:246 | INFO | 🔄 Iteration 3/20
2025-09-22 03:50:20 | memu.memory.memory_agent:297 | INFO | 🔧 Calling function: generate_memory_suggestions
2025-09-22 03:50:27 | memu.memory.memory_agent:306 | INFO | Function time used: 7.28 seconds
2025-09-22 03:50:27 | memu.memory.memory_agent:246 | INFO | 🔄 Iteration 4/20
2025-09-22 03:50:36 | memu.memory.memory_agent:297 | INFO | 🔧 Calling function: update_memory_with_suggestions
2025-09-22 03:50:41 | memu.memory.actions.update_memory_with_suggestions:414 | WARNING | Failed to generate embedding for memory item 4c578b: AttributeError("'NoneType' object has no attribute 'embed'")
2025-09-22 03:50:41 | memu.memory.actions.update_memory_with_suggestions:414 | WARNING | Failed to generate embedding for memory item d420fe: AttributeError("'NoneType' object has no attribute 'embed'")
2025-09-22 03:50:41 | memu.memory.memory_agent:306 | INFO | Function time used: 4.86 seconds
2025-09-22 03:50:41 | memu.memory.memory_agent:297 | INFO | 🔧 Calling function: update_memory_with_suggestions
2025-09-22 03:50:46 | memu.memory.actions.update_memory_with_suggestions:414 | WARNING | Failed to generate embedding for memory item 1bbf1f: AttributeError("'NoneType' object has no attribute 'embed'")
2025-09-22 03:50:46 | memu.memory.memory_agent:306 | INFO | Function time used: 5.49 seconds
2025-09-22 03:50:46 | memu.memory.memory_agent:246 | INFO | 🔄 Iteration 5/20
2025-09-22 03:50:53 | memu.memory.memory_agent:297 | INFO | 🔧 Calling function: link_related_memories
2025-09-22 03:50:53 | memu.memory.actions.base_action:124 | ERROR | Action link_related_memories failed: 'NoneType' object has no attribute 'embed'
2025-09-22 03:50:53 | memu.memory.memory_agent:306 | INFO | Function time used: 0.00 seconds
2025-09-22 03:50:53 | memu.memory.memory_agent:297 | INFO | 🔧 Calling function: link_related_memories
2025-09-22 03:50:53 | memu.memory.actions.base_action:124 | ERROR | Action link_related_memories failed: 'NoneType' object has no attribute 'embed'
2025-09-22 03:50:53 | memu.memory.memory_agent:306 | INFO | Function time used: 0.00 seconds
Currently, the self-hosted deployment cannot create API keys and is unusable. The error you reported is due to an issue with the embedding model, as DeepSeek does not provide an embedding model.