Updated docs for agent_id and run_id (#3294)
This commit is contained in:
@@ -296,7 +296,7 @@ The Mem0's graph supports the following operations:
|
||||
### Add Memories
|
||||
|
||||
<Note>
|
||||
Mem0 with Graph Memory supports both "user_id" and "agent_id" parameters. You can use either or both to organize your memories. Use "userId" and "agentId" in NodeSDK.
|
||||
Mem0 with Graph Memory supports "user_id", "agent_id", and "run_id" parameters. You can use any combination of these to organize your memories. Use "userId", "agentId", and "runId" in NodeSDK.
|
||||
</Note>
|
||||
|
||||
<CodeGroup>
|
||||
@@ -306,6 +306,9 @@ m.add("I like pizza", user_id="alice")
|
||||
|
||||
# Using both user_id and agent_id
|
||||
m.add("I like pizza", user_id="alice", agent_id="food-assistant")
|
||||
|
||||
# Using all three parameters for maximum organization
|
||||
m.add("I like pizza", user_id="alice", agent_id="food-assistant", run_id="session-123")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
@@ -331,6 +334,12 @@ m.get_all(user_id="alice")
|
||||
|
||||
# Get all memories for a specific agent belonging to a user
|
||||
m.get_all(user_id="alice", agent_id="food-assistant")
|
||||
|
||||
# Get all memories for a specific run/session
|
||||
m.get_all(user_id="alice", run_id="session-123")
|
||||
|
||||
# Get all memories for a specific agent and run combination
|
||||
m.get_all(user_id="alice", agent_id="food-assistant", run_id="session-123")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
@@ -375,6 +384,12 @@ m.search("tell me my name.", user_id="alice")
|
||||
|
||||
# Search memories for a specific agent belonging to a user
|
||||
m.search("tell me my name.", user_id="alice", agent_id="food-assistant")
|
||||
|
||||
# Search memories for a specific run/session
|
||||
m.search("tell me my name.", user_id="alice", run_id="session-123")
|
||||
|
||||
# Search memories for a specific agent and run combination
|
||||
m.search("tell me my name.", user_id="alice", agent_id="food-assistant", run_id="session-123")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
@@ -611,12 +626,13 @@ memory.search("Who is spiderman?", { userId: "alice123" });
|
||||
## Using Multiple Agents with Graph Memory
|
||||
|
||||
|
||||
When working with multiple agents, you can use the "agent_id" parameter to organize memories by both user and agent. This allows you to:
|
||||
|
||||
When working with multiple agents and sessions, you can use the "agent_id" and "run_id" parameters to organize memories by user, agent, and run context. This allows you to:
|
||||
|
||||
1. Create agent-specific knowledge graphs
|
||||
2. Share common knowledge between agents
|
||||
3. Isolate sensitive or specialized information to specific agents
|
||||
4. Track conversation sessions and runs separately
|
||||
5. Maintain context across different execution contexts
|
||||
|
||||
### Example: Multi-Agent Setup
|
||||
|
||||
@@ -627,10 +643,17 @@ m.add("I prefer Italian cuisine", user_id="bob", agent_id="food-assistant")
|
||||
m.add("I'm allergic to peanuts", user_id="bob", agent_id="health-assistant")
|
||||
m.add("I live in Seattle", user_id="bob") # Shared across all agents
|
||||
|
||||
# Add memories for specific runs/sessions
|
||||
m.add("Current session: discussing dinner plans", user_id="bob", agent_id="food-assistant", run_id="dinner-session-001")
|
||||
m.add("Previous session: allergy consultation", user_id="bob", agent_id="health-assistant", run_id="health-session-001")
|
||||
|
||||
# Search within specific agent context
|
||||
food_preferences = m.search("What food do I like?", user_id="bob", agent_id="food-assistant")
|
||||
health_info = m.search("What are my allergies?", user_id="bob", agent_id="health-assistant")
|
||||
location = m.search("Where do I live?", user_id="bob") # Searches across all agents
|
||||
|
||||
# Search within specific run context
|
||||
current_session = m.search("What are we discussing?", user_id="bob", run_id="dinner-session-001")
|
||||
```
|
||||
|
||||
```typescript TypeScript
|
||||
|
||||
Reference in New Issue
Block a user