Update Docs (#3315)

This commit is contained in:
Deshraj Yadav
2025-08-13 21:37:15 -07:00
committed by GitHub
parent 5e895c240a
commit 192db1844c
127 changed files with 2882 additions and 3317 deletions
+146 -9
View File
@@ -4,8 +4,6 @@ icon: "thumbs-up"
iconType: "solid"
---
<Snippet file="blank-notif.mdx" />
Mem0's **Feedback Mechanism** allows you to provide feedback on the memories generated by your application. This feedback is used to improve the accuracy of the memories and the search results.
## How it works
@@ -50,15 +48,154 @@ The `feedback` parameter can be one of the following values:
## Parameters
The `feedback` method takes the following parameters:
The `feedback` method accepts these parameters:
- `memory_id`: The ID of the memory to give feedback on.
- `feedback`: The feedback to give on the memory. (Optional)
- `feedback_reason`: The reason for the feedback. (Optional)
The `feedback_reason` parameter is optional and can be used to provide a reason for the feedback.
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `memory_id` | string | Yes | The ID of the memory to give feedback on |
| `feedback` | string | No | Type of feedback: `POSITIVE`, `NEGATIVE`, or `VERY_NEGATIVE` |
| `feedback_reason` | string | No | Optional explanation for the feedback |
<Note>
You can pass `None` or `null` to the `feedback` and `feedback_reason` parameters to remove the feedback for a memory.
Pass `None` or `null` to the `feedback` and `feedback_reason` parameters to remove existing feedback for a memory.
</Note>
## Bulk Feedback Operations
For applications with high volumes of feedback, you can provide feedback on multiple memories at once:
<CodeGroup>
```python Python
from mem0 import MemoryClient
client = MemoryClient(api_key="your_api_key")
# Bulk feedback example
feedback_data = [
{
"memory_id": "memory-1",
"feedback": "POSITIVE",
"feedback_reason": "Accurately captured the user's preference"
},
{
"memory_id": "memory-2",
"feedback": "NEGATIVE",
"feedback_reason": "Contains outdated information"
}
]
for item in feedback_data:
client.feedback(**item)
```
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: 'your-api-key'});
// Bulk feedback example
const feedbackData = [
{
memory_id: "memory-1",
feedback: "POSITIVE",
feedback_reason: "Accurately captured the user's preference"
},
{
memory_id: "memory-2",
feedback: "NEGATIVE",
feedback_reason: "Contains outdated information"
}
];
for (const item of feedbackData) {
await client.feedback(item);
}
```
</CodeGroup>
## Best Practices
### When to Provide Feedback
- **Immediately after memory retrieval** when you can assess relevance
- **During user interactions** when users explicitly indicate satisfaction/dissatisfaction
- **Through automated evaluation** using your application's success metrics
### Effective Feedback Reasons
Provide specific, actionable feedback reasons:
✅ **Good examples:**
- "Contains outdated contact information"
- "Accurately captured the user's dietary restrictions"
- "Irrelevant to the current conversation context"
❌ **Avoid vague reasons:**
- "Bad memory"
- "Wrong"
- "Not good"
### Feedback Strategy
1. **Be consistent** - Apply the same criteria across similar memories
2. **Be specific** - Detailed reasons help improve the system faster
3. **Monitor patterns** - Regular feedback analysis helps identify improvement areas
## Error Handling
Handle potential errors when submitting feedback:
<CodeGroup>
```python Python
from mem0 import MemoryClient
from mem0.exceptions import MemoryNotFoundError, APIError
client = MemoryClient(api_key="your_api_key")
try:
client.feedback(
memory_id="memory-123",
feedback="POSITIVE",
feedback_reason="Helpful context for user query"
)
print("Feedback submitted successfully")
except MemoryNotFoundError:
print("Memory not found")
except APIError as e:
print(f"API error: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
```
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: 'your-api-key'});
try {
await client.feedback({
memory_id: "memory-123",
feedback: "POSITIVE",
feedback_reason: "Helpful context for user query"
});
console.log("Feedback submitted successfully");
} catch (error) {
if (error.status === 404) {
console.log("Memory not found");
} else {
console.log(`Error: ${error.message}`);
}
}
```
</CodeGroup>
## Feedback Analytics
Track the impact of your feedback by monitoring memory performance over time. Consider implementing:
- **Feedback completion rates** - What percentage of memories receive feedback
- **Feedback distribution** - Balance of positive vs. negative feedback
- **Memory quality trends** - How accuracy improves with feedback volume
- **User satisfaction metrics** - Correlation between feedback and user experience