[docs] API References and search Doc fix (#3712)
This commit is contained in:
@@ -16,7 +16,7 @@ The v2 get memories API is powerful and flexible, allowing for more precise memo
|
|||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Code
|
||||||
memories = m.get_all(
|
memories = client.get_all(
|
||||||
filters={
|
filters={
|
||||||
"AND": [
|
"AND": [
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,7 @@ To retrieve graph memory relationships between entities, pass `output_format="v1
|
|||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Code
|
||||||
memories = m.get_all(
|
memories = client.get_all(
|
||||||
filters={
|
filters={
|
||||||
"user_id": "alex"
|
"user_id": "alex"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ The v2 search API is powerful and flexible, allowing for more precise memory ret
|
|||||||
- `*`: Wildcard character that matches everything
|
- `*`: Wildcard character that matches everything
|
||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Code
|
```python Platform API Example
|
||||||
related_memories = m.search(
|
related_memories = client.search(
|
||||||
query="What are Alice's hobbies?",
|
query="What are Alice's hobbies?",
|
||||||
filters={
|
filters={
|
||||||
"OR": [
|
"OR": [
|
||||||
@@ -53,7 +53,7 @@ related_memories = m.search(
|
|||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Wildcard Example
|
```python Wildcard Example
|
||||||
# Using wildcard to match all run_ids for a specific user
|
# Using wildcard to match all run_ids for a specific user
|
||||||
all_memories = m.search(
|
all_memories = client.search(
|
||||||
query="What are Alice's hobbies?",
|
query="What are Alice's hobbies?",
|
||||||
filters={
|
filters={
|
||||||
"AND": [
|
"AND": [
|
||||||
@@ -72,7 +72,7 @@ all_memories = m.search(
|
|||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
```python Categories Filter Examples
|
```python Categories Filter Examples
|
||||||
# Example 1: Using 'contains' for partial matching
|
# Example 1: Using 'contains' for partial matching
|
||||||
finance_memories = m.search(
|
finance_memories = client.search(
|
||||||
query="What are my financial goals?",
|
query="What are my financial goals?",
|
||||||
filters={
|
filters={
|
||||||
"AND": [
|
"AND": [
|
||||||
@@ -87,7 +87,7 @@ finance_memories = m.search(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Example 2: Using 'in' for exact matching
|
# Example 2: Using 'in' for exact matching
|
||||||
personal_memories = m.search(
|
personal_memories = client.search(
|
||||||
query="What personal information do you have?",
|
query="What personal information do you have?",
|
||||||
filters={
|
filters={
|
||||||
"AND": [
|
"AND": [
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ iconType: "solid"
|
|||||||
|
|
||||||
# How Mem0 Searches Memory
|
# How Mem0 Searches Memory
|
||||||
|
|
||||||
Mem0’s search operation lets agents ask natural-language questions and get back the memories that matter most. It’s the bridge between everything you’ve stored and the next response your agent writes.
|
Mem0's search operation lets agents ask natural-language questions and get back the memories that matter most. Like a smart librarian, it finds exactly what you need from everything you've stored.
|
||||||
|
|
||||||
<Info>
|
<Info>
|
||||||
**Why it matters**
|
**Why it matters**
|
||||||
@@ -46,7 +46,39 @@ Formatted memories (with metadata and timestamps) return to your agent or callin
|
|||||||
|
|
||||||
This pipeline runs the same way for the hosted Platform API and the OSS SDK.
|
This pipeline runs the same way for the hosted Platform API and the OSS SDK.
|
||||||
|
|
||||||
---
|
## How does it work?
|
||||||
|
|
||||||
|
Search converts your natural language question into a vector embedding, then finds memories with similar embeddings in your database. The results are ranked by similarity score and can be further refined with filters or reranking.
|
||||||
|
|
||||||
|
```python
|
||||||
|
# Minimal example that shows the concept in action
|
||||||
|
# Platform API
|
||||||
|
client.search("What are Alice's hobbies?", filters={"user_id": "alice"})
|
||||||
|
|
||||||
|
# OSS
|
||||||
|
m.search("What are Alice's hobbies?", user_id="alice")
|
||||||
|
```
|
||||||
|
|
||||||
|
<Tip>
|
||||||
|
Always provide at least a `user_id` filter to scope searches to the right user's memories. This prevents cross-contamination between users.
|
||||||
|
</Tip>
|
||||||
|
|
||||||
|
## When should you use it?
|
||||||
|
|
||||||
|
- **Context retrieval** - When your agent needs past context to generate better responses
|
||||||
|
- **Personalization** - To recall user preferences, history, or past interactions
|
||||||
|
- **Fact checking** - To verify information against stored memories before responding
|
||||||
|
- **Decision support** - When agents need relevant background information to make decisions
|
||||||
|
|
||||||
|
## Platform vs OSS usage
|
||||||
|
|
||||||
|
| Capability | Mem0 Platform | Mem0 OSS |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| **user_id usage** | In `filters={"user_id": "alice"}` for search/get_all | As parameter `user_id="alice"` for all operations |
|
||||||
|
| **Filter syntax** | Logical operators (`AND`, `OR`, comparisons) with field-level access | Basic field filters, extend via Python hooks |
|
||||||
|
| **Reranking** | Toggle `rerank=True` with managed reranker catalog | Requires configuring local or third-party rerankers |
|
||||||
|
| **Thresholds** | Request-level configuration (`threshold`, `top_k`) | Controlled via SDK parameters |
|
||||||
|
| **Response metadata** | Includes confidence scores, timestamps, dashboard visibility | Determined by your storage backend |
|
||||||
|
|
||||||
## Search with Mem0 Platform
|
## Search with Mem0 Platform
|
||||||
|
|
||||||
@@ -85,8 +117,6 @@ const results = await client.search(query, {
|
|||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Search with Mem0 Open Source
|
## Search with Mem0 Open Source
|
||||||
|
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
@@ -122,8 +152,6 @@ const memories = memory.search("food preferences", {
|
|||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
<Info icon="check">
|
<Info icon="check">
|
||||||
Expect an array of memory documents. Platform responses include vectors, metadata, and timestamps; OSS returns your stored schema.
|
Expect an array of memory documents. Platform responses include vectors, metadata, and timestamps; OSS returns your stored schema.
|
||||||
</Info>
|
</Info>
|
||||||
@@ -133,6 +161,20 @@ const memories = memory.search("food preferences", {
|
|||||||
Filters help narrow down search results. Common use cases:
|
Filters help narrow down search results. Common use cases:
|
||||||
|
|
||||||
**Filter by Session Context:**
|
**Filter by Session Context:**
|
||||||
|
|
||||||
|
*Platform API:*
|
||||||
|
```python
|
||||||
|
# Get memories from a specific agent session
|
||||||
|
client.search("query", filters={
|
||||||
|
"AND": [
|
||||||
|
{"user_id": "alice"},
|
||||||
|
{"agent_id": "chatbot"},
|
||||||
|
{"run_id": "session-123"}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
*OSS:*
|
||||||
```python
|
```python
|
||||||
# Get memories from a specific agent session
|
# Get memories from a specific agent session
|
||||||
m.search("query", user_id="alice", agent_id="chatbot", run_id="session-123")
|
m.search("query", user_id="alice", agent_id="chatbot", run_id="session-123")
|
||||||
@@ -160,32 +202,22 @@ client.search("preferences", filters={
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Tips for better search
|
## Tips for better search
|
||||||
|
|
||||||
- **Use natural language**: Mem0 understands intent, so describe what you're looking for naturally
|
- **Use natural language**: Mem0 understands intent, so describe what you're looking for naturally
|
||||||
- **Scope with session IDs**: Always provide at least `user_id` to scope search to relevant memories
|
- **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
|
||||||
- **Combine filters**: Use AND/OR logic to create precise queries (Platform)
|
- **Combine filters**: Use AND/OR logic to create precise queries (Platform)
|
||||||
- **Consider wildcard filters**: Use wildcard filters (e.g., `run_id: "*"`) for broader matches
|
- **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
|
- **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) when you have a reranker configured
|
||||||
|
|
||||||
|
|
||||||
### More Details
|
### More Details
|
||||||
|
|
||||||
For the full list of filter logic, comparison operators, and optional search parameters, see the
|
For the full list of filter logic, comparison operators, and optional search parameters, see the
|
||||||
[Search Memory API Reference](/api-reference/memory/search-memories).
|
[Search Memory API Reference](/api-reference/memory/search-memories).
|
||||||
|
|
||||||
## Managed vs OSS differences
|
|
||||||
|
|
||||||
| Capability | Mem0 Platform | Mem0 OSS |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| Filters | Logical operators (`AND`, `OR`, comparisons) with field-level access | Basic field filters, extend via Python hooks |
|
|
||||||
| Reranking | Toggle `rerank=True` with managed reranker catalog | Requires configuring local or third-party rerankers |
|
|
||||||
| Thresholds | Request-level configuration (`threshold`, `top_k`) | Controlled via SDK parameters |
|
|
||||||
| Response metadata | Includes confidence scores, timestamps, dashboard visibility | Determined by your storage backend |
|
|
||||||
|
|
||||||
## Put it into practice
|
## Put it into practice
|
||||||
|
|
||||||
- Revisit the <Link href="/core-concepts/memory-operations/add">Add Memory</Link> guide to ensure you capture the context you expect to retrieve.
|
- Revisit the <Link href="/core-concepts/memory-operations/add">Add Memory</Link> guide to ensure you capture the context you expect to retrieve.
|
||||||
@@ -200,15 +232,15 @@ For the full list of filter logic, comparison operators, and optional search par
|
|||||||
|
|
||||||
<CardGroup cols={2}>
|
<CardGroup cols={2}>
|
||||||
<Card
|
<Card
|
||||||
title="Tune Update Concepts"
|
title="Search Memory API"
|
||||||
description="Learn how to adjust memories after search results come back."
|
description="Complete API reference with all filter operators and parameters."
|
||||||
icon="pencil"
|
icon="book"
|
||||||
href="/core-concepts/memory-operations/update"
|
href="/api-reference/memory/search-memories"
|
||||||
/>
|
/>
|
||||||
<Card
|
<Card
|
||||||
title="Build Hybrid Search"
|
title="Support Inbox Cookbook"
|
||||||
description="Follow the cookbook to combine Mem0 with external search."
|
description="Build a complete support system with scoped search and reranking."
|
||||||
icon="rocket"
|
icon="rocket"
|
||||||
href="/cookbooks/integrations/tavily-search"
|
href="/cookbooks/operations/support-inbox"
|
||||||
/>
|
/>
|
||||||
</CardGroup>
|
</CardGroup>
|
||||||
@@ -677,7 +677,6 @@
|
|||||||
"group": "\ud83d\udca1 Examples",
|
"group": "\ud83d\udca1 Examples",
|
||||||
"icon": "lightbulb",
|
"icon": "lightbulb",
|
||||||
"pages": [
|
"pages": [
|
||||||
"examples",
|
|
||||||
"v0x/examples/mem0-demo",
|
"v0x/examples/mem0-demo",
|
||||||
"v0x/examples/ai_companion_js",
|
"v0x/examples/ai_companion_js",
|
||||||
"v0x/examples/mem0-with-ollama",
|
"v0x/examples/mem0-with-ollama",
|
||||||
|
|||||||
Reference in New Issue
Block a user