agenticmem 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of agenticmem might be problematic. Click here for more details.
- agenticmem-0.1.0/PKG-INFO +102 -0
- agenticmem-0.1.0/README.md +83 -0
- agenticmem-0.1.0/agenticmem/__init__.py +29 -0
- agenticmem-0.1.0/agenticmem/client.py +203 -0
- agenticmem-0.1.0/pyproject.toml +18 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: agenticmem
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python client for the AgenticMem API
|
|
5
|
+
License: MIT
|
|
6
|
+
Author: AgenticMem Team
|
|
7
|
+
Requires-Python: >=3.7,<4.0
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
16
|
+
Requires-Dist: python-dateutil (>=2.8.0,<3.0.0)
|
|
17
|
+
Requires-Dist: requests (>=2.25.0,<3.0.0)
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# AgenticMem Python Client
|
|
21
|
+
|
|
22
|
+
A Python client library for interacting with the AgenticMem API. This client provides easy-to-use interfaces for managing user interactions and profiles.
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install agenticmem
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from agenticmem import AgenticMemClient
|
|
34
|
+
from agenticmem import UserActionType, InteractionRequest
|
|
35
|
+
from datetime import datetime
|
|
36
|
+
|
|
37
|
+
# Initialize the client
|
|
38
|
+
client = AgenticMemClient(
|
|
39
|
+
api_key="your_api_key",
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# Publish a user interaction
|
|
43
|
+
interaction = InteractionRequest(
|
|
44
|
+
timestamp=datetime.now(),
|
|
45
|
+
text_interaction="User clicked on product X",
|
|
46
|
+
user_action=UserActionType.CLICK,
|
|
47
|
+
user_action_description="Clicked on product details button"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
response = client.publish_interaction(
|
|
51
|
+
user_id="user123",
|
|
52
|
+
request_id="req456",
|
|
53
|
+
interaction_requests=[interaction]
|
|
54
|
+
)
|
|
55
|
+
print(f"Published interaction: {response.success} - {response.message}")
|
|
56
|
+
|
|
57
|
+
# Search user profiles
|
|
58
|
+
profiles = client.search_profiles(
|
|
59
|
+
user_id="user123",
|
|
60
|
+
query="recent interactions",
|
|
61
|
+
top_k=5
|
|
62
|
+
)
|
|
63
|
+
for profile in profiles:
|
|
64
|
+
print(f"Profile {profile.profile_id}: {profile.profile_content}")
|
|
65
|
+
|
|
66
|
+
# Search interactions
|
|
67
|
+
interactions = client.search_interactions(
|
|
68
|
+
user_id="user123",
|
|
69
|
+
start_time=datetime(2024, 1, 1),
|
|
70
|
+
end_time=datetime.now()
|
|
71
|
+
)
|
|
72
|
+
for interaction in interactions:
|
|
73
|
+
print(f"Interaction {interaction.interaction_id}: {interaction.text_interaction}")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Features
|
|
77
|
+
|
|
78
|
+
- User interaction management
|
|
79
|
+
- Publish user interactions
|
|
80
|
+
- Delete user interactions
|
|
81
|
+
- Search interactions
|
|
82
|
+
- User profile management
|
|
83
|
+
- Search user profiles
|
|
84
|
+
- Delete user profiles
|
|
85
|
+
|
|
86
|
+
## API Response Types
|
|
87
|
+
|
|
88
|
+
All API methods return strongly-typed responses:
|
|
89
|
+
|
|
90
|
+
- `publish_interaction()` returns `PublishUserInteractionResponse`
|
|
91
|
+
- `search_interactions()` returns `List[Interaction]`
|
|
92
|
+
- `search_profiles()` returns `List[UserProfile]`
|
|
93
|
+
- `delete_profile()` returns `DeleteUserProfileResponse`
|
|
94
|
+
- `delete_interaction()` returns `DeleteUserInteractionResponse`
|
|
95
|
+
|
|
96
|
+
## Documentation
|
|
97
|
+
|
|
98
|
+
For detailed documentation, please visit [docs link].
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT License
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# AgenticMem Python Client
|
|
2
|
+
|
|
3
|
+
A Python client library for interacting with the AgenticMem API. This client provides easy-to-use interfaces for managing user interactions and profiles.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install agenticmem
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from agenticmem import AgenticMemClient
|
|
15
|
+
from agenticmem import UserActionType, InteractionRequest
|
|
16
|
+
from datetime import datetime
|
|
17
|
+
|
|
18
|
+
# Initialize the client
|
|
19
|
+
client = AgenticMemClient(
|
|
20
|
+
api_key="your_api_key",
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# Publish a user interaction
|
|
24
|
+
interaction = InteractionRequest(
|
|
25
|
+
timestamp=datetime.now(),
|
|
26
|
+
text_interaction="User clicked on product X",
|
|
27
|
+
user_action=UserActionType.CLICK,
|
|
28
|
+
user_action_description="Clicked on product details button"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
response = client.publish_interaction(
|
|
32
|
+
user_id="user123",
|
|
33
|
+
request_id="req456",
|
|
34
|
+
interaction_requests=[interaction]
|
|
35
|
+
)
|
|
36
|
+
print(f"Published interaction: {response.success} - {response.message}")
|
|
37
|
+
|
|
38
|
+
# Search user profiles
|
|
39
|
+
profiles = client.search_profiles(
|
|
40
|
+
user_id="user123",
|
|
41
|
+
query="recent interactions",
|
|
42
|
+
top_k=5
|
|
43
|
+
)
|
|
44
|
+
for profile in profiles:
|
|
45
|
+
print(f"Profile {profile.profile_id}: {profile.profile_content}")
|
|
46
|
+
|
|
47
|
+
# Search interactions
|
|
48
|
+
interactions = client.search_interactions(
|
|
49
|
+
user_id="user123",
|
|
50
|
+
start_time=datetime(2024, 1, 1),
|
|
51
|
+
end_time=datetime.now()
|
|
52
|
+
)
|
|
53
|
+
for interaction in interactions:
|
|
54
|
+
print(f"Interaction {interaction.interaction_id}: {interaction.text_interaction}")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Features
|
|
58
|
+
|
|
59
|
+
- User interaction management
|
|
60
|
+
- Publish user interactions
|
|
61
|
+
- Delete user interactions
|
|
62
|
+
- Search interactions
|
|
63
|
+
- User profile management
|
|
64
|
+
- Search user profiles
|
|
65
|
+
- Delete user profiles
|
|
66
|
+
|
|
67
|
+
## API Response Types
|
|
68
|
+
|
|
69
|
+
All API methods return strongly-typed responses:
|
|
70
|
+
|
|
71
|
+
- `publish_interaction()` returns `PublishUserInteractionResponse`
|
|
72
|
+
- `search_interactions()` returns `List[Interaction]`
|
|
73
|
+
- `search_profiles()` returns `List[UserProfile]`
|
|
74
|
+
- `delete_profile()` returns `DeleteUserProfileResponse`
|
|
75
|
+
- `delete_interaction()` returns `DeleteUserInteractionResponse`
|
|
76
|
+
|
|
77
|
+
## Documentation
|
|
78
|
+
|
|
79
|
+
For detailed documentation, please visit [docs link].
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
|
|
83
|
+
MIT License
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from agenticmem.client import AgenticMemClient
|
|
2
|
+
from server.api_schema.service_schemas import (
|
|
3
|
+
UserActionType,
|
|
4
|
+
ProfileTimeToLive,
|
|
5
|
+
InteractionRequest,
|
|
6
|
+
Interaction,
|
|
7
|
+
UserProfile,
|
|
8
|
+
PublishUserInteractionRequest,
|
|
9
|
+
PublishUserInteractionResponse,
|
|
10
|
+
DeleteUserProfileRequest,
|
|
11
|
+
DeleteUserProfileResponse,
|
|
12
|
+
DeleteUserInteractionRequest,
|
|
13
|
+
DeleteUserInteractionResponse,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
'AgenticMemClient',
|
|
18
|
+
'UserActionType',
|
|
19
|
+
'ProfileTimeToLive',
|
|
20
|
+
'InteractionRequest',
|
|
21
|
+
'Interaction',
|
|
22
|
+
'UserProfile',
|
|
23
|
+
'PublishUserInteractionRequest',
|
|
24
|
+
'PublishUserInteractionResponse',
|
|
25
|
+
'DeleteUserProfileRequest',
|
|
26
|
+
'DeleteUserProfileResponse',
|
|
27
|
+
'DeleteUserInteractionRequest',
|
|
28
|
+
'DeleteUserInteractionResponse',
|
|
29
|
+
]
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
import requests
|
|
4
|
+
from urllib.parse import urljoin
|
|
5
|
+
|
|
6
|
+
from server.api_schema.service_schemas import (
|
|
7
|
+
Interaction,
|
|
8
|
+
InteractionRequest,
|
|
9
|
+
UserProfile,
|
|
10
|
+
PublishUserInteractionRequest,
|
|
11
|
+
PublishUserInteractionResponse,
|
|
12
|
+
DeleteUserProfileRequest,
|
|
13
|
+
DeleteUserProfileResponse,
|
|
14
|
+
DeleteUserInteractionRequest,
|
|
15
|
+
DeleteUserInteractionResponse,
|
|
16
|
+
)
|
|
17
|
+
from server.api_schema.login_schema import Token
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class AgenticMemClient:
|
|
21
|
+
"""Client for interacting with the AgenticMem API."""
|
|
22
|
+
|
|
23
|
+
def __init__(self, api_key: str):
|
|
24
|
+
"""Initialize the AgenticMem client.
|
|
25
|
+
|
|
26
|
+
Args:
|
|
27
|
+
api_key (str): Your API key for authentication
|
|
28
|
+
"""
|
|
29
|
+
self.api_key = api_key
|
|
30
|
+
self.base_url = "https://api.agenticmem.com"
|
|
31
|
+
self.session = requests.Session()
|
|
32
|
+
self.session.headers.update({
|
|
33
|
+
"Authorization": f"Bearer {api_key}",
|
|
34
|
+
"Content-Type": "application/json"
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
def _make_request(self, method: str, endpoint: str, **kwargs):
|
|
38
|
+
"""Make an HTTP request to the API.
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
method (str): HTTP method (GET, POST, DELETE)
|
|
42
|
+
endpoint (str): API endpoint
|
|
43
|
+
**kwargs: Additional arguments to pass to requests
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
dict: API response
|
|
47
|
+
"""
|
|
48
|
+
url = urljoin(self.base_url, endpoint)
|
|
49
|
+
response = self.session.request(method, url, **kwargs)
|
|
50
|
+
response.raise_for_status()
|
|
51
|
+
return response.json()
|
|
52
|
+
|
|
53
|
+
def login(self, email: str, password: str) -> Token:
|
|
54
|
+
"""Login to the AgenticMem API.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
email (str): The user's email
|
|
58
|
+
password (str): The user's password
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Token: Response containing success status and message
|
|
62
|
+
"""
|
|
63
|
+
response = self._make_request("POST", "/api/login", json={"email": email, "password": password})
|
|
64
|
+
return Token(**response)
|
|
65
|
+
|
|
66
|
+
def publish_interaction(
|
|
67
|
+
self,
|
|
68
|
+
user_id: str,
|
|
69
|
+
request_id: str,
|
|
70
|
+
interaction_requests: List[InteractionRequest]
|
|
71
|
+
) -> PublishUserInteractionResponse:
|
|
72
|
+
"""Publish user interactions.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
user_id (str): The user ID
|
|
76
|
+
request_id (str): The request ID
|
|
77
|
+
interaction_requests (List[InteractionRequest]): List of interaction requests
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
PublishUserInteractionResponse: Response containing success status and message
|
|
81
|
+
"""
|
|
82
|
+
request = PublishUserInteractionRequest(
|
|
83
|
+
user_id=user_id,
|
|
84
|
+
request_id=request_id,
|
|
85
|
+
interaction_requests=interaction_requests
|
|
86
|
+
)
|
|
87
|
+
response = self._make_request("POST", "/api/interactions", json=request.model_dump())
|
|
88
|
+
return PublishUserInteractionResponse(**response)
|
|
89
|
+
|
|
90
|
+
def search_interactions(
|
|
91
|
+
self,
|
|
92
|
+
user_id: str,
|
|
93
|
+
request_id: Optional[str] = None,
|
|
94
|
+
query: Optional[str] = None,
|
|
95
|
+
start_time: Optional[datetime] = None,
|
|
96
|
+
end_time: Optional[datetime] = None,
|
|
97
|
+
most_recent_k: Optional[int] = None
|
|
98
|
+
) -> List[Interaction]:
|
|
99
|
+
"""Search for user interactions.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
user_id (str): The user ID
|
|
103
|
+
request_id (Optional[str], optional): Filter by request ID
|
|
104
|
+
query (Optional[str], optional): Search query
|
|
105
|
+
start_time (Optional[datetime], optional): Start time filter
|
|
106
|
+
end_time (Optional[datetime], optional): End time filter
|
|
107
|
+
most_recent_k (Optional[int], optional): Limit to most recent K results
|
|
108
|
+
|
|
109
|
+
Returns:
|
|
110
|
+
List[Interaction]: List of matching interactions
|
|
111
|
+
"""
|
|
112
|
+
params = {
|
|
113
|
+
"user_id": user_id,
|
|
114
|
+
"request_id": request_id,
|
|
115
|
+
"query": query,
|
|
116
|
+
"start_time": start_time,
|
|
117
|
+
"end_time": end_time,
|
|
118
|
+
"most_recent_k": most_recent_k
|
|
119
|
+
}
|
|
120
|
+
# Remove None values
|
|
121
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
122
|
+
response = self._make_request("GET", "/api/interactions/search", params=params)
|
|
123
|
+
return [Interaction(**interaction) for interaction in response.get("interactions", [])]
|
|
124
|
+
|
|
125
|
+
def search_profiles(
|
|
126
|
+
self,
|
|
127
|
+
user_id: str,
|
|
128
|
+
genered_from_request_id: Optional[str] = None,
|
|
129
|
+
query: Optional[str] = None,
|
|
130
|
+
start_time: Optional[datetime] = None,
|
|
131
|
+
end_time: Optional[datetime] = None,
|
|
132
|
+
top_k: Optional[int] = None
|
|
133
|
+
) -> List[UserProfile]:
|
|
134
|
+
"""Search for user profiles.
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
user_id (str): The user ID
|
|
138
|
+
genered_from_request_id (Optional[str], optional): Filter by request ID that generated the profile
|
|
139
|
+
query (Optional[str], optional): Search query
|
|
140
|
+
start_time (Optional[datetime], optional): Start time filter
|
|
141
|
+
end_time (Optional[datetime], optional): End time filter
|
|
142
|
+
top_k (Optional[int], optional): Limit to top K results
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
List[UserProfile]: List of matching profiles
|
|
146
|
+
"""
|
|
147
|
+
params = {
|
|
148
|
+
"user_id": user_id,
|
|
149
|
+
"genered_from_request_id": genered_from_request_id,
|
|
150
|
+
"query": query,
|
|
151
|
+
"start_time": start_time,
|
|
152
|
+
"end_time": end_time,
|
|
153
|
+
"top_k": top_k
|
|
154
|
+
}
|
|
155
|
+
# Remove None values
|
|
156
|
+
params = {k: v for k, v in params.items() if v is not None}
|
|
157
|
+
response = self._make_request("GET", "/api/profiles/search", params=params)
|
|
158
|
+
return [UserProfile(**profile) for profile in response.get("user_profiles", [])]
|
|
159
|
+
|
|
160
|
+
def delete_profile(
|
|
161
|
+
self,
|
|
162
|
+
user_id: str,
|
|
163
|
+
profile_id: str = "",
|
|
164
|
+
profile_search_query: str = ""
|
|
165
|
+
) -> DeleteUserProfileResponse:
|
|
166
|
+
"""Delete user profiles.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
user_id (str): The user ID
|
|
170
|
+
profile_id (str, optional): Specific profile ID to delete
|
|
171
|
+
profile_search_query (str, optional): Query to match profiles for deletion
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
DeleteUserProfileResponse: Response containing success status and message
|
|
175
|
+
"""
|
|
176
|
+
request = DeleteUserProfileRequest(
|
|
177
|
+
user_id=user_id,
|
|
178
|
+
profile_id=profile_id,
|
|
179
|
+
profile_search_query=profile_search_query
|
|
180
|
+
)
|
|
181
|
+
response = self._make_request("DELETE", "/api/profiles", json=request.model_dump())
|
|
182
|
+
return DeleteUserProfileResponse(**response)
|
|
183
|
+
|
|
184
|
+
def delete_interaction(
|
|
185
|
+
self,
|
|
186
|
+
user_id: str,
|
|
187
|
+
interaction_id: str
|
|
188
|
+
) -> DeleteUserInteractionResponse:
|
|
189
|
+
"""Delete a user interaction.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
user_id (str): The user ID
|
|
193
|
+
interaction_id (str): The interaction ID to delete
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
DeleteUserInteractionResponse: Response containing success status and message
|
|
197
|
+
"""
|
|
198
|
+
request = DeleteUserInteractionRequest(
|
|
199
|
+
user_id=user_id,
|
|
200
|
+
interaction_id=interaction_id
|
|
201
|
+
)
|
|
202
|
+
response = self._make_request("DELETE", "/api/interactions", json=request.model_dump())
|
|
203
|
+
return DeleteUserInteractionResponse(**response)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "agenticmem"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A Python client for the AgenticMem API"
|
|
5
|
+
authors = ["AgenticMem Team"]
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
packages = [{include = "agenticmem"}]
|
|
8
|
+
license = "MIT"
|
|
9
|
+
|
|
10
|
+
[tool.poetry.dependencies]
|
|
11
|
+
python = "^3.7"
|
|
12
|
+
requests = "^2.25.0"
|
|
13
|
+
pydantic = "^2.0.0"
|
|
14
|
+
python-dateutil = "^2.8.0"
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["poetry-core"]
|
|
18
|
+
build-backend = "poetry.core.masonry.api"
|