Skip to content

Commit 6215017

Browse files
authored
Merge pull request #657 from pipecat-ai/docs/pr-4156
docs: update for pipecat PR #4156
2 parents 8291499 + 5a2c355 commit 6215017

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

server/services/memory/mem0.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,27 @@ memory = Mem0MemoryService(
152152
)
153153
```
154154

155+
### Retrieving Memories Outside the Pipeline
156+
157+
The `get_memories()` method allows you to access stored memories outside the normal pipeline flow, such as when creating a personalized greeting at connection time:
158+
159+
```python
160+
# Get all stored memories for the configured user/agent/run IDs
161+
memories = await memory.get_memories()
162+
163+
# Create a personalized greeting
164+
if memories:
165+
greeting = "Hello! Based on our previous conversations, I remember: "
166+
for mem in memories[:3]:
167+
greeting += f"{mem['memory']} "
168+
else:
169+
greeting = "Hello! It's nice to meet you."
170+
```
171+
155172
## Notes
156173

157174
- **At least one ID required**: You must provide at least one of `user_id`, `agent_id`, or `run_id`. A `ValueError` is raised if none are provided.
158175
- **Cloud vs local**: Use `api_key` for Mem0's cloud API, or `local_config` for a self-hosted Mem0 instance using `Memory.from_config()`.
159176
- **Pipeline placement**: Place the `Mem0MemoryService` before your LLM service in the pipeline. It intercepts `LLMContextFrame`, `OpenAILLMContextFrame`, and `LLMMessagesFrame` to enhance context with relevant memories before passing them downstream.
177+
- **Non-blocking operation**: All Mem0 API calls (storage, retrieval, search) run in background threads to avoid blocking the event loop. Message storage is fire-and-forget, so it doesn't delay downstream processing.
178+
- **Message role filtering**: Only messages with `user` or `assistant` roles are stored in Mem0. Messages with other roles (such as `system` or `developer`) are automatically filtered out, as the Mem0 API does not accept them.

0 commit comments

Comments
 (0)