agenticmem 0.1.1__py3-none-any.whl → 0.1.2.1__py3-none-any.whl
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/client.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import aiohttp
|
|
2
2
|
from urllib.parse import urljoin
|
|
3
3
|
import os
|
|
4
|
+
import requests
|
|
4
5
|
from typing import Optional, Union
|
|
5
6
|
from agenticmem_commons.api_schema.retriever_schema import (
|
|
6
7
|
SearchInteractionRequest,
|
|
@@ -13,7 +14,7 @@ from agenticmem_commons.api_schema.retriever_schema import (
|
|
|
13
14
|
GetUserProfilesResponse,
|
|
14
15
|
)
|
|
15
16
|
|
|
16
|
-
if os.environ.get("TEST_ENV",
|
|
17
|
+
if os.environ.get("TEST_ENV", True):
|
|
17
18
|
BACKEND_URL = "http://127.0.0.1:8000" # Local server for testing
|
|
18
19
|
else:
|
|
19
20
|
BACKEND_URL = "http://agenticmem-test.us-west-2.elasticbeanstalk.com:8081" # Elastic Beanstalk server url
|
|
@@ -34,16 +35,38 @@ from agenticmem_commons.api_schema.login_schema import Token
|
|
|
34
35
|
class AgenticMemClient:
|
|
35
36
|
"""Client for interacting with the AgenticMem API."""
|
|
36
37
|
|
|
37
|
-
def __init__(self, api_key: str = ""):
|
|
38
|
+
def __init__(self, api_key: str = "", url_endpoint: str = ""):
|
|
38
39
|
"""Initialize the AgenticMem client.
|
|
39
40
|
|
|
40
41
|
Args:
|
|
41
42
|
api_key (str): Your API key for authentication
|
|
42
43
|
"""
|
|
43
44
|
self.api_key = api_key
|
|
44
|
-
self.base_url = BACKEND_URL
|
|
45
|
+
self.base_url = url_endpoint if url_endpoint else BACKEND_URL
|
|
45
46
|
self.session = requests.Session()
|
|
46
47
|
|
|
48
|
+
async def _make_async_request(
|
|
49
|
+
self, method: str, endpoint: str, headers: Optional[dict] = None, **kwargs
|
|
50
|
+
):
|
|
51
|
+
"""Make an async HTTP request to the API."""
|
|
52
|
+
url = urljoin(self.base_url, endpoint)
|
|
53
|
+
|
|
54
|
+
headers = headers or {}
|
|
55
|
+
if self.api_key:
|
|
56
|
+
headers.update(
|
|
57
|
+
{
|
|
58
|
+
"Authorization": f"Bearer {self.api_key}",
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
async with aiohttp.ClientSession() as async_session:
|
|
64
|
+
response = await async_session.request(
|
|
65
|
+
method, url, headers=headers, **kwargs
|
|
66
|
+
)
|
|
67
|
+
response.raise_for_status()
|
|
68
|
+
return await response.json()
|
|
69
|
+
|
|
47
70
|
def _make_request(
|
|
48
71
|
self, method: str, endpoint: str, headers: Optional[dict] = None, **kwargs
|
|
49
72
|
):
|
|
@@ -72,17 +95,9 @@ class AgenticMemClient:
|
|
|
72
95
|
response.raise_for_status()
|
|
73
96
|
return response.json()
|
|
74
97
|
|
|
75
|
-
def login(self, email: str, password: str) -> Token:
|
|
76
|
-
"""
|
|
77
|
-
|
|
78
|
-
Args:
|
|
79
|
-
email (str): The user's email
|
|
80
|
-
password (str): The user's password
|
|
81
|
-
|
|
82
|
-
Returns:
|
|
83
|
-
Token: Response containing success status and message
|
|
84
|
-
"""
|
|
85
|
-
response = self._make_request(
|
|
98
|
+
async def login(self, email: str, password: str) -> Token:
|
|
99
|
+
"""Async login to the AgenticMem API."""
|
|
100
|
+
response = await self._make_async_request(
|
|
86
101
|
"POST",
|
|
87
102
|
"/token",
|
|
88
103
|
data={"username": email, "password": password},
|
|
@@ -93,11 +108,13 @@ class AgenticMemClient:
|
|
|
93
108
|
)
|
|
94
109
|
return Token(**response)
|
|
95
110
|
|
|
96
|
-
def publish_interaction(
|
|
111
|
+
async def publish_interaction(
|
|
97
112
|
self,
|
|
98
113
|
request_id: str,
|
|
99
114
|
user_id: str,
|
|
100
115
|
interaction_requests: list[Union[InteractionRequest, dict]],
|
|
116
|
+
source: str = "",
|
|
117
|
+
agent_version: str = "",
|
|
101
118
|
) -> PublishUserInteractionResponse:
|
|
102
119
|
"""Publish user interactions.
|
|
103
120
|
|
|
@@ -105,7 +122,7 @@ class AgenticMemClient:
|
|
|
105
122
|
request_id (str): The request ID
|
|
106
123
|
user_id (str): The user ID
|
|
107
124
|
interaction_requests (List[InteractionRequest]): List of interaction requests
|
|
108
|
-
|
|
125
|
+
source (str, optional): The source of the interaction
|
|
109
126
|
Returns:
|
|
110
127
|
PublishUserInteractionResponse: Response containing success status and message
|
|
111
128
|
"""
|
|
@@ -121,15 +138,17 @@ class AgenticMemClient:
|
|
|
121
138
|
request_id=request_id,
|
|
122
139
|
user_id=user_id,
|
|
123
140
|
interaction_requests=interaction_requests,
|
|
141
|
+
source=source,
|
|
142
|
+
agent_version=agent_version,
|
|
124
143
|
)
|
|
125
|
-
response = self.
|
|
144
|
+
response = await self._make_async_request(
|
|
126
145
|
"POST",
|
|
127
146
|
"/api/publish_interaction",
|
|
128
|
-
|
|
147
|
+
json=request.model_dump(),
|
|
129
148
|
)
|
|
130
149
|
return PublishUserInteractionResponse(**response)
|
|
131
150
|
|
|
132
|
-
def search_interactions(
|
|
151
|
+
async def search_interactions(
|
|
133
152
|
self,
|
|
134
153
|
request: Union[SearchInteractionRequest, dict],
|
|
135
154
|
) -> SearchInteractionResponse:
|
|
@@ -143,14 +162,14 @@ class AgenticMemClient:
|
|
|
143
162
|
"""
|
|
144
163
|
if isinstance(request, dict):
|
|
145
164
|
request = SearchInteractionRequest(**request)
|
|
146
|
-
response = self.
|
|
165
|
+
response = await self._make_async_request(
|
|
147
166
|
"POST",
|
|
148
167
|
"/api/search_interactions",
|
|
149
|
-
|
|
168
|
+
json=request.model_dump(),
|
|
150
169
|
)
|
|
151
170
|
return SearchInteractionResponse(**response)
|
|
152
171
|
|
|
153
|
-
def search_profiles(
|
|
172
|
+
async def search_profiles(
|
|
154
173
|
self,
|
|
155
174
|
request: Union[SearchUserProfileRequest, dict],
|
|
156
175
|
) -> SearchUserProfileResponse:
|
|
@@ -164,12 +183,12 @@ class AgenticMemClient:
|
|
|
164
183
|
"""
|
|
165
184
|
if isinstance(request, dict):
|
|
166
185
|
request = SearchUserProfileRequest(**request)
|
|
167
|
-
response = self.
|
|
168
|
-
"POST", "/api/search_profiles",
|
|
186
|
+
response = await self._make_async_request(
|
|
187
|
+
"POST", "/api/search_profiles", json=request.model_dump()
|
|
169
188
|
)
|
|
170
189
|
return SearchUserProfileResponse(**response)
|
|
171
190
|
|
|
172
|
-
def delete_profile(
|
|
191
|
+
async def delete_profile(
|
|
173
192
|
self, user_id: str, profile_id: str = "", search_query: str = ""
|
|
174
193
|
) -> DeleteUserProfileResponse:
|
|
175
194
|
"""Delete user profiles.
|
|
@@ -187,12 +206,12 @@ class AgenticMemClient:
|
|
|
187
206
|
profile_id=profile_id,
|
|
188
207
|
search_query=search_query,
|
|
189
208
|
)
|
|
190
|
-
response = self.
|
|
191
|
-
"DELETE", "/api/delete_profile",
|
|
209
|
+
response = await self._make_async_request(
|
|
210
|
+
"DELETE", "/api/delete_profile", json=request.model_dump()
|
|
192
211
|
)
|
|
193
212
|
return DeleteUserProfileResponse(**response)
|
|
194
213
|
|
|
195
|
-
def delete_interaction(
|
|
214
|
+
async def delete_interaction(
|
|
196
215
|
self, user_id: str, interaction_id: str
|
|
197
216
|
) -> DeleteUserInteractionResponse:
|
|
198
217
|
"""Delete a user interaction.
|
|
@@ -207,16 +226,16 @@ class AgenticMemClient:
|
|
|
207
226
|
request = DeleteUserInteractionRequest(
|
|
208
227
|
user_id=user_id, interaction_id=interaction_id
|
|
209
228
|
)
|
|
210
|
-
response = self.
|
|
211
|
-
"DELETE", "/api/delete_interaction",
|
|
229
|
+
response = await self._make_async_request(
|
|
230
|
+
"DELETE", "/api/delete_interaction", json=request.model_dump()
|
|
212
231
|
)
|
|
213
232
|
return DeleteUserInteractionResponse(**response)
|
|
214
233
|
|
|
215
|
-
def get_profile_change_log(self) -> ProfileChangeLogResponse:
|
|
216
|
-
response = self.
|
|
234
|
+
async def get_profile_change_log(self) -> ProfileChangeLogResponse:
|
|
235
|
+
response = await self._make_async_request("GET", "/api/profile_change_log")
|
|
217
236
|
return ProfileChangeLogResponse(**response)
|
|
218
237
|
|
|
219
|
-
def get_interactions(
|
|
238
|
+
async def get_interactions(
|
|
220
239
|
self,
|
|
221
240
|
request: Union[GetInteractionsRequest, dict],
|
|
222
241
|
) -> GetInteractionsResponse:
|
|
@@ -230,14 +249,14 @@ class AgenticMemClient:
|
|
|
230
249
|
"""
|
|
231
250
|
if isinstance(request, dict):
|
|
232
251
|
request = GetInteractionsRequest(**request)
|
|
233
|
-
response = self.
|
|
252
|
+
response = await self._make_async_request(
|
|
234
253
|
"POST",
|
|
235
254
|
"/api/get_interactions",
|
|
236
|
-
|
|
255
|
+
json=request.model_dump(),
|
|
237
256
|
)
|
|
238
257
|
return GetInteractionsResponse(**response)
|
|
239
258
|
|
|
240
|
-
def get_profiles(
|
|
259
|
+
async def get_profiles(
|
|
241
260
|
self,
|
|
242
261
|
request: Union[GetUserProfilesRequest, dict],
|
|
243
262
|
) -> GetUserProfilesResponse:
|
|
@@ -251,9 +270,9 @@ class AgenticMemClient:
|
|
|
251
270
|
"""
|
|
252
271
|
if isinstance(request, dict):
|
|
253
272
|
request = GetUserProfilesRequest(**request)
|
|
254
|
-
response = self.
|
|
273
|
+
response = await self._make_async_request(
|
|
255
274
|
"POST",
|
|
256
275
|
"/api/get_profiles",
|
|
257
|
-
|
|
276
|
+
json=request.model_dump(),
|
|
258
277
|
)
|
|
259
278
|
return GetUserProfilesResponse(**response)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: agenticmem
|
|
3
|
-
Version: 0.1.1
|
|
3
|
+
Version: 0.1.2.1
|
|
4
4
|
Summary: A Python client for the AgenticMem API
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: AgenticMem Team
|
|
@@ -9,7 +9,10 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.10
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Requires-Dist: agenticmem-commons (==0.1.2)
|
|
15
|
+
Requires-Dist: aiohttp (>=3.12.9,<4.0.0)
|
|
13
16
|
Requires-Dist: griffe (==0.48.0)
|
|
14
17
|
Requires-Dist: mkdocstrings[python] (>=0.18.0)
|
|
15
18
|
Requires-Dist: pydantic (>=2.0.0,<3.0.0)
|
|
@@ -33,7 +36,7 @@ pip install agenticmem
|
|
|
33
36
|
from agenticmem import AgenticMemClient
|
|
34
37
|
from agenticmem_commons.api_schema.service_schemas import InteractionRequest
|
|
35
38
|
from agenticmem_commons.api_schema.retriever_schema import (
|
|
36
|
-
SearchInteractionRequest,
|
|
39
|
+
SearchInteractionRequest,
|
|
37
40
|
SearchUserProfileRequest,
|
|
38
41
|
GetInteractionsRequest,
|
|
39
42
|
GetUserProfilesRequest
|
|
@@ -48,8 +51,8 @@ token = client.login(email="user@example.com", password="password123")
|
|
|
48
51
|
|
|
49
52
|
# Publish a user interaction
|
|
50
53
|
interaction = InteractionRequest(
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
created_at=int(datetime.utcnow().timestamp()),
|
|
55
|
+
content="User clicked on product X",
|
|
53
56
|
user_action="click",
|
|
54
57
|
user_action_description="Clicked on product details button"
|
|
55
58
|
)
|
|
@@ -87,7 +90,7 @@ interactions_request = SearchInteractionRequest(
|
|
|
87
90
|
)
|
|
88
91
|
interactions = client.search_interactions(interactions_request)
|
|
89
92
|
for interaction in interactions.interactions:
|
|
90
|
-
print(f"Interaction {interaction.interaction_id}: {interaction.
|
|
93
|
+
print(f"Interaction {interaction.interaction_id}: {interaction.content}")
|
|
91
94
|
|
|
92
95
|
# Get interactions directly
|
|
93
96
|
interactions_request = GetInteractionsRequest(
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
agenticmem/__init__.py,sha256=zjj8VIn65S5NzJZV64IUG8G1p0J-9SYBJJMSof8mDU8,1229
|
|
2
|
+
agenticmem/client.py,sha256=zTXWz3FeW68511r8mMt-kF-OhAYePLv02tswoL1oNpM,9412
|
|
3
|
+
agenticmem/client_utils.py,sha256=kWTWlyO7s768v38ef41nRDq87Qmb60NX2vmZTVlCB6g,297
|
|
4
|
+
agenticmem-0.1.2.1.dist-info/METADATA,sha256=M7QTy_AWaMTT5Tvgz-uTks-k73qcTGAJBQqtbpd7Gd0,4459
|
|
5
|
+
agenticmem-0.1.2.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
6
|
+
agenticmem-0.1.2.1.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
agenticmem/__init__.py,sha256=zjj8VIn65S5NzJZV64IUG8G1p0J-9SYBJJMSof8mDU8,1229
|
|
2
|
-
agenticmem/client.py,sha256=_ZRjGFsxHnFdrCoQJEu8ofioxZYvI1vSlRCsMK8-Z5g,8480
|
|
3
|
-
agenticmem/client_utils.py,sha256=kWTWlyO7s768v38ef41nRDq87Qmb60NX2vmZTVlCB6g,297
|
|
4
|
-
agenticmem-0.1.1.dist-info/METADATA,sha256=ccLBT23K7aLygLLscXgSJxu2VY7FzCgFijAW1V0CdAI,4332
|
|
5
|
-
agenticmem-0.1.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
|
6
|
-
agenticmem-0.1.1.dist-info/RECORD,,
|