diff --git a/docs/core-concepts/memory-operations/search.mdx b/docs/core-concepts/memory-operations/search.mdx index 487700a61..08582cd42 100644 --- a/docs/core-concepts/memory-operations/search.mdx +++ b/docs/core-concepts/memory-operations/search.mdx @@ -238,11 +238,11 @@ client.search("preferences", filters={ - **Use natural language**: Mem0 understands intent, so describe what you're looking for naturally - **Scope with user ID**: Always provide `user_id` to scope search to relevant memories - **Platform API**: Use `filters={"user_id": "alice"}` - - **OSS**: Use `user_id="alice"` as parameter + - **OSS**: Use `filters={"user_id": "alice"}` (passing `user_id` as a top-level kwarg raises `ValueError` in v3) - **Combine filters**: Use AND/OR logic to create precise queries (Platform) - **Consider wildcard filters**: Use wildcard filters (e.g., `run_id: "*"`) for broader matches - **Tune parameters**: Adjust `top_k` for result count, `threshold` for relevance cutoff -- **Enable reranking**: Use `rerank=True` (default) when you have a reranker configured +- **Enable reranking**: Use `rerank=True` (default is `False`) when you have a reranker configured **MCP Alternative**: With Mem0 MCP, AI agents can search their own memories proactively when needed. diff --git a/docs/core-concepts/memory-types.mdx b/docs/core-concepts/memory-types.mdx index 9be7fc412..7ee20e899 100644 --- a/docs/core-concepts/memory-types.mdx +++ b/docs/core-concepts/memory-types.mdx @@ -60,7 +60,7 @@ import os from mem0 import Memory -memory = Memory(api_key=os.environ["MEM0_API_KEY"]) +memory = Memory() # Sticky note: conversation memory memory.add( @@ -72,8 +72,7 @@ memory.add( # Later in the session, pull long-term + session context results = memory.search( "Any hotel preferences?", - user_id="alex", - run_id="trip-planning-2025", + filters={"user_id": "alex", "run_id": "trip-planning-2025"}, ) ``` diff --git a/docs/platform/advanced-memory-operations.mdx b/docs/platform/advanced-memory-operations.mdx index cbbb5efd6..c1cb8a689 100644 --- a/docs/platform/advanced-memory-operations.mdx +++ b/docs/platform/advanced-memory-operations.mdx @@ -9,7 +9,6 @@ description: "Run richer add/search/update/delete flows on the managed platform **Prerequisites** - Platform workspace with API key - Python 3.10+ and Node.js 18+ - - Async memories enabled in your dashboard (Settings → Memory Options) @@ -21,9 +20,9 @@ description: "Run richer add/search/update/delete flows on the managed platform - + ```bash -pip install "mem0ai[async]" +pip install mem0ai ``` @@ -55,9 +54,9 @@ export MEM0_API_KEY="sk-platform-..." ```typescript -import { Memory } from "mem0ai"; +import MemoryClient from 'mem0ai'; -const memory = new Memory({ apiKey: process.env.MEM0_API_KEY!, async: true }); +const memory = new MemoryClient({ apiKey: process.env.MEM0_API_KEY! }); ``` @@ -121,10 +120,8 @@ const result = await memory.add(conversation, { ```python matches = await memory.search( "Any food alerts?", - user_id="traveler-42", - filters={"metadata.trip": "japan-2025"}, + filters={"user_id": "traveler-42", "metadata.trip": "japan-2025"}, rerank=True, - include_vectors=False, ) ``` @@ -132,7 +129,7 @@ matches = await memory.search( ```python await memory.update( memory_id=matches["results"][0]["id"], - content="Morgan avoids shellfish and prefers boutique hotels in central Tokyo.", + data="Morgan avoids shellfish and prefers boutique hotels in central Tokyo.", ) ``` @@ -143,17 +140,15 @@ await memory.update( ```typescript const matches = await memory.search("Any food alerts?", { - userId: "traveler-42", - filters: { "metadata.trip": "japan-2025" }, + filters: { user_id: "traveler-42", "metadata.trip": "japan-2025" }, rerank: true, - includeVectors: false, }); ``` ```typescript await memory.update(matches.results[0].id, { - content: "Morgan avoids shellfish and prefers boutique hotels in central Tokyo.", + text: "Morgan avoids shellfish and prefers boutique hotels in central Tokyo.", }); ``` diff --git a/docs/platform/features/advanced-retrieval.mdx b/docs/platform/features/advanced-retrieval.mdx index 0dce8efbf..43470da5d 100644 --- a/docs/platform/features/advanced-retrieval.mdx +++ b/docs/platform/features/advanced-retrieval.mdx @@ -26,7 +26,7 @@ Reorders results using deep semantic understanding to put the most relevant memo results = client.search( query="What are my upcoming travel plans?", rerank=True, - user_id="user123" + filters={"user_id": "user123"}, ) # Before reranking: After reranking: @@ -52,7 +52,7 @@ results = client.search( results = client.search( query="How do I like my bedroom temperature?", rerank=True, # Get most recent preferences first - user_id="user123" + filters={"user_id": "user123"}, ) # Finds: "Keep bedroom at 68°F", "Too cold last night at 65°F", etc. @@ -63,7 +63,7 @@ results = client.search( # Find specific product issues with high precision results = client.search( query="Problems with premium subscription billing", - user_id="customer456" + filters={"user_id": "customer456"}, ) # Returns only relevant billing problems, not general questions @@ -75,7 +75,7 @@ results = client.search( results = client.search( query="Patient allergies and contraindications", rerank=True, # Most important info first - user_id="patient789" + filters={"user_id": "patient789"}, ) # Ensures critical allergy info appears first @@ -87,7 +87,7 @@ results = client.search( results = client.search( query="Python programming progress and difficulties", rerank=True, # Recent progress first - user_id="student123" + filters={"user_id": "student123"}, ) # Gets comprehensive view of Python learning journey @@ -105,7 +105,7 @@ results = client.search( def quick_search(query, user_id): return client.search( query=query, - user_id=user_id + filters={"user_id": user_id}, ) # Reranked search - good for most applications @@ -113,7 +113,7 @@ def standard_search(query, user_id): return client.search( query=query, rerank=True, - user_id=user_id + filters={"user_id": user_id}, ) # Reranked search - good for critical applications @@ -121,7 +121,7 @@ def precise_search(query, user_id): return client.search( query=query, rerank=True, - user_id=user_id + filters={"user_id": user_id}, ) ``` @@ -129,23 +129,23 @@ def precise_search(query, user_id): // Basic search - good for exploration function quickSearch(query, userId) { return client.search(query, { - user_id: userId + filters: { user_id: userId }, }); } // Reranked search - good for most applications function standardSearch(query, userId) { return client.search(query, { - user_id: userId, - rerank: true + filters: { user_id: userId }, + rerank: true, }); } // Reranked search - good for critical applications function preciseSearch(query, userId) { return client.search(query, { - user_id: userId, - rerank: true + filters: { user_id: userId }, + rerank: true, }); } ``` @@ -178,7 +178,7 @@ start_time = time.time() results = client.search( query="user preferences", rerank=True, # +150ms - user_id="user123" + filters={"user_id": "user123"}, ) latency = time.time() - start_time print(f"Search completed in {latency:.2f}s") diff --git a/docs/platform/features/contextual-add.mdx b/docs/platform/features/contextual-add.mdx index 1344e1ca3..bf55a1a30 100644 --- a/docs/platform/features/contextual-add.mdx +++ b/docs/platform/features/contextual-add.mdx @@ -25,7 +25,7 @@ const messages = [ {"role": "assistant", "content": "Great! I'll remember your preference for Italian cuisine."} ]; -await client.add(messages, { userId: "user123", version: "v2" }); +await client.add(messages, { userId: "user123" }); ``` @@ -65,14 +65,14 @@ const messages1 = [ {"role": "user", "content": "Hi, I'm Sarah from New York"}, {"role": "assistant", "content": "Hello Sarah! Nice to meet you."} ]; -await client.add(messages1, { userId: "sarah", version: "v2" }); +await client.add(messages1, { userId: "sarah" }); // Later interaction - just send new messages const messages2 = [ {"role": "user", "content": "I'm planning a trip to Italy next month"}, {"role": "assistant", "content": "How exciting! Italy is beautiful this time of year."} ]; -await client.add(messages2, { userId: "sarah", version: "v2" }); +await client.add(messages2, { userId: "sarah" }); // Mem0 automatically knows Sarah is from New York and can use this context ``` @@ -104,7 +104,7 @@ const messages = [ {"role": "assistant", "content": "I've noted your allergies for future reference."} ]; -await client.add(messages, { userId: "user123", version: "v2" }); +await client.add(messages, { userId: "user123" }); // This allergy info will be available in ALL future interactions ``` @@ -143,21 +143,21 @@ const messages1 = [ {"role": "user", "content": "I want to plan a 5-day trip to Tokyo"}, {"role": "assistant", "content": "Perfect! Let's plan your Tokyo adventure."} ]; -await client.add(messages1, { userId: "user123", runId: "tokyo-trip-2024", version: "v2" }); +await client.add(messages1, { userId: "user123", runId: "tokyo-trip-2024" }); // Later in the same trip planning session const messages2 = [ {"role": "user", "content": "I prefer staying near Shibuya"}, {"role": "assistant", "content": "Great choice! Shibuya is very convenient."} ]; -await client.add(messages2, { userId: "user123", runId: "tokyo-trip-2024", version: "v2" }); +await client.add(messages2, { userId: "user123", runId: "tokyo-trip-2024" }); // Different session for work project (separate context) const workMessages = [ {"role": "user", "content": "Let's discuss the Q4 marketing strategy"}, {"role": "assistant", "content": "Sure! What are your main goals for Q4?"} ]; -await client.add(workMessages, { userId: "user123", runId: "q4-marketing", version: "v2" }); +await client.add(workMessages, { userId: "user123", runId: "q4-marketing" }); ``` diff --git a/docs/platform/features/criteria-retrieval.mdx b/docs/platform/features/criteria-retrieval.mdx index fef71822e..883540cc8 100644 --- a/docs/platform/features/criteria-retrieval.mdx +++ b/docs/platform/features/criteria-retrieval.mdx @@ -182,7 +182,7 @@ If no criteria are defined for a project, search behaves normally based on seman This lets you prioritize memories that align with your agent's goals and not just those that look similar to the query. -Criteria retrieval is automatically enabled when criteria are defined in your project. Use `use_criteria=False` in search to temporarily disable it for a specific query. +Criteria retrieval is automatically enabled when criteria are defined in your project. Use `use_criteria=False` in search to temporarily disable it for a specific query. `use_criteria` is a server-side parameter passed through to the Platform API — it is not a typed option in the SDK's `SearchMemoryOptions` interface, but the server accepts and processes it when included in the request body. diff --git a/docs/platform/features/feedback-mechanism.mdx b/docs/platform/features/feedback-mechanism.mdx index a74a267b4..8950f1ea6 100644 --- a/docs/platform/features/feedback-mechanism.mdx +++ b/docs/platform/features/feedback-mechanism.mdx @@ -150,7 +150,7 @@ Handle potential errors when submitting feedback: ```python Python from mem0 import MemoryClient -from mem0.exceptions import MemoryNotFoundError, APIError +from mem0.exceptions import MemoryNotFoundError, NetworkError client = MemoryClient(api_key="your_api_key") @@ -163,8 +163,8 @@ try: print("Feedback submitted successfully") except MemoryNotFoundError: print("Memory not found") -except APIError as e: - print(f"API error: {e}") +except NetworkError as e: + print(f"Network error: {e}") except Exception as e: print(f"Unexpected error: {e}") ``` diff --git a/docs/platform/features/group-chat.mdx b/docs/platform/features/group-chat.mdx index caf490812..cd0408f15 100644 --- a/docs/platform/features/group-chat.mdx +++ b/docs/platform/features/group-chat.mdx @@ -111,32 +111,37 @@ print(all_memories) ``` ```json Output -[ - { - "id": "147559a8-c5f7-44d0-9418-91f53f7a89a4", - "memory": "suggests considering Angular because it has great enterprise support", - "user_id": "charlie", - "run_id": "group_chat_1", - "created_at": "2025-06-21T05:51:11.007223-07:00", - "updated_at": "2025-06-21T05:51:11.626562-07:00" - }, - { - "id": "1d8b8f39-7b17-4d18-8632-ab1c64fa35b9", - "memory": "prefers Vue.js for our use case", - "user_id": "bob", - "run_id": "group_chat_1", - "created_at": "2025-06-21T05:51:08.675301-07:00", - "updated_at": "2025-06-21T05:51:09.319269-07:00", - }, - { - "id": "4d82478a-8d50-47e6-9324-1f65efff5829", - "memory": "prefers using React for the frontend", - "user_id": "alice", - "run_id": "group_chat_1", - "created_at": "2025-06-21T05:51:05.943223-07:00", - "updated_at": "2025-06-21T05:51:06.982539-07:00", - } -] +{ + "count": 3, + "next": null, + "previous": null, + "results": [ + { + "id": "147559a8-c5f7-44d0-9418-91f53f7a89a4", + "memory": "suggests considering Angular because it has great enterprise support", + "user_id": "charlie", + "run_id": "group_chat_1", + "created_at": "2025-06-21T05:51:11.007223-07:00", + "updated_at": "2025-06-21T05:51:11.626562-07:00" + }, + { + "id": "1d8b8f39-7b17-4d18-8632-ab1c64fa35b9", + "memory": "prefers Vue.js for our use case", + "user_id": "bob", + "run_id": "group_chat_1", + "created_at": "2025-06-21T05:51:08.675301-07:00", + "updated_at": "2025-06-21T05:51:09.319269-07:00" + }, + { + "id": "4d82478a-8d50-47e6-9324-1f65efff5829", + "memory": "prefers using React for the frontend", + "user_id": "alice", + "run_id": "group_chat_1", + "created_at": "2025-06-21T05:51:05.943223-07:00", + "updated_at": "2025-06-21T05:51:06.982539-07:00" + } + ] +} ``` @@ -161,17 +166,21 @@ print(charlie_memories) ``` ```json Output -[ - { - "id": "147559a8-c5f7-44d0-9418-91f53f7a89a4", - "memory": "suggests considering Angular because it has great enterprise support", - "user_id": "charlie", - "run_id": "group_chat_1", - "created_at": "2025-06-21T05:51:11.007223-07:00", - "updated_at": "2025-06-21T05:51:11.626562-07:00", - - } -] +{ + "count": 1, + "next": null, + "previous": null, + "results": [ + { + "id": "147559a8-c5f7-44d0-9418-91f53f7a89a4", + "memory": "suggests considering Angular because it has great enterprise support", + "user_id": "charlie", + "run_id": "group_chat_1", + "created_at": "2025-06-21T05:51:11.007223-07:00", + "updated_at": "2025-06-21T05:51:11.626562-07:00" + } + ] +} ``` @@ -199,16 +208,18 @@ print(search_response) ``` ```json Output -[ - { - "id": "147559a8-c5f7-44d0-9418-91f53f7a89a4", - "memory": "suggests considering Angular because it has great enterprise support", - "user_id": "charlie", - "run_id": "group_chat_1", - "created_at": "2025-06-21T05:51:11.007223-07:00", - "updated_at": "2025-06-21T05:51:11.626562-07:00", - } -] +{ + "results": [ + { + "id": "147559a8-c5f7-44d0-9418-91f53f7a89a4", + "memory": "suggests considering Angular because it has great enterprise support", + "user_id": "charlie", + "run_id": "group_chat_1", + "created_at": "2025-06-21T05:51:11.007223-07:00", + "updated_at": "2025-06-21T05:51:11.626562-07:00" + } + ] +} ``` diff --git a/docs/platform/features/memory-export.mdx b/docs/platform/features/memory-export.mdx index 7703b1199..0a0d67612 100644 --- a/docs/platform/features/memory-export.mdx +++ b/docs/platform/features/memory-export.mdx @@ -251,7 +251,6 @@ You can apply various filters to customize which memories are included in the ex - `user_id`: Filter memories by specific user - `agent_id`: Filter memories by specific agent - `run_id`: Filter memories by specific run -- `session_id`: Filter memories by specific session - `created_at`: Filter memories by date diff --git a/docs/platform/mem0-mcp.mdx b/docs/platform/mem0-mcp.mdx index 6f605f0fc..8ba439a8e 100644 --- a/docs/platform/mem0-mcp.mdx +++ b/docs/platform/mem0-mcp.mdx @@ -9,7 +9,7 @@ estimatedTime: "~2 minutes" **Prerequisites** - Mem0 Platform account (Sign up here) - API key (Get one from dashboard) - - Node.js 14+ (for npx) + - Node.js 18+ (for npx) - An MCP-compatible client (Claude, Claude Code, Codex, Cursor, Windsurf, VS Code, OpenCode) diff --git a/docs/platform/quickstart.mdx b/docs/platform/quickstart.mdx index 3618427b0..9b6a3dfe3 100644 --- a/docs/platform/quickstart.mdx +++ b/docs/platform/quickstart.mdx @@ -15,7 +15,7 @@ Get started with Mem0 Platform's hosted API in under 5 minutes. This guide shows - Mem0 Platform account (Sign up here) - API key (Get one from dashboard) -- Python 3.10+, Node.js 14+, or cURL +- Python 3.10+, Node.js 18+, or cURL ## Installation