[Mem0] Add support for getting all users in python client (#1672)
This commit is contained in:
@@ -230,6 +230,59 @@ curl -X POST "https://api.mem0.ai/v1/memories/search/" \
|
|||||||
```
|
```
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
|
|
||||||
|
### 4.3 Get all users
|
||||||
|
|
||||||
|
Get all users, agents, and sessions for which memories exist.
|
||||||
|
|
||||||
|
<CodeGroup>
|
||||||
|
|
||||||
|
```python Python
|
||||||
|
client.users()
|
||||||
|
```
|
||||||
|
|
||||||
|
```javascript JavaScript
|
||||||
|
client.users()
|
||||||
|
.then(users => console.log(users))
|
||||||
|
.catch(error => console.error(error));
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash cURL
|
||||||
|
curl -X GET "https://api.mem0.ai/v1/entities/" \
|
||||||
|
-H "Authorization: Token your-api-key"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```json Output
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "1",
|
||||||
|
"name": "user123",
|
||||||
|
"created_at": "2024-07-17T16:47:23.899900-07:00",
|
||||||
|
"updated_at": "2024-07-17T16:47:23.899918-07:00",
|
||||||
|
"total_memories": 5,
|
||||||
|
"owner": "alex",
|
||||||
|
"organization": "alex-org",
|
||||||
|
"metadata": {"foo": "bar"},
|
||||||
|
"type": "user"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2",
|
||||||
|
"name": "travel-agent",
|
||||||
|
"created_at": "2024-07-01T17:59:08.187250-07:00",
|
||||||
|
"updated_at": "2024-07-01T17:59:08.187266-07:00",
|
||||||
|
"total_memories": 10,
|
||||||
|
"owner": "alex",
|
||||||
|
"organization": "alex-org",
|
||||||
|
"metadata": {"agent_id": "123"},
|
||||||
|
"type": "agent"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
</CodeGroup>
|
||||||
|
|
||||||
|
|
||||||
### 4.3 Get All Memories
|
### 4.3 Get All Memories
|
||||||
|
|
||||||
Fetch all memories for a user, agent, or session using the getAll() method.
|
Fetch all memories for a user, agent, or session using the getAll() method.
|
||||||
|
|||||||
@@ -237,6 +237,14 @@ class MemoryClient:
|
|||||||
capture_client_event("client.history", self)
|
capture_client_event("client.history", self)
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
@api_error_handler
|
||||||
|
def users(self):
|
||||||
|
"""Get all users, agents, and sessions for which memories exist."""
|
||||||
|
response = self.client.get("/entities/")
|
||||||
|
response.raise_for_status()
|
||||||
|
capture_client_event("client.users", self)
|
||||||
|
return response.json()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""Reset the client. (Not implemented)
|
"""Reset the client. (Not implemented)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "mem0ai"
|
name = "mem0ai"
|
||||||
version = "0.0.14"
|
version = "0.0.15"
|
||||||
description = "Long-term memory for AI Agents"
|
description = "Long-term memory for AI Agents"
|
||||||
authors = ["Mem0 <founders@mem0.ai>"]
|
authors = ["Mem0 <founders@mem0.ai>"]
|
||||||
exclude = [
|
exclude = [
|
||||||
|
|||||||
Reference in New Issue
Block a user