agenticmem 0.1.1__tar.gz → 0.1.2__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.

@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: agenticmem
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: A Python client for the AgenticMem API
5
5
  License: MIT
6
6
  Author: AgenticMem Team
@@ -9,7 +9,9 @@ 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
- Requires-Dist: agenticmem-commons (==0.1.1)
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: agenticmem-commons (==0.1.2)
13
15
  Requires-Dist: griffe (==0.48.0)
14
16
  Requires-Dist: mkdocstrings[python] (>=0.18.0)
15
17
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
@@ -33,7 +35,7 @@ pip install agenticmem
33
35
  from agenticmem import AgenticMemClient
34
36
  from agenticmem_commons.api_schema.service_schemas import InteractionRequest
35
37
  from agenticmem_commons.api_schema.retriever_schema import (
36
- SearchInteractionRequest,
38
+ SearchInteractionRequest,
37
39
  SearchUserProfileRequest,
38
40
  GetInteractionsRequest,
39
41
  GetUserProfilesRequest
@@ -48,8 +50,8 @@ token = client.login(email="user@example.com", password="password123")
48
50
 
49
51
  # Publish a user interaction
50
52
  interaction = InteractionRequest(
51
- timestamp=int(datetime.utcnow().timestamp()),
52
- text_interaction="User clicked on product X",
53
+ created_at=int(datetime.utcnow().timestamp()),
54
+ content="User clicked on product X",
53
55
  user_action="click",
54
56
  user_action_description="Clicked on product details button"
55
57
  )
@@ -87,7 +89,7 @@ interactions_request = SearchInteractionRequest(
87
89
  )
88
90
  interactions = client.search_interactions(interactions_request)
89
91
  for interaction in interactions.interactions:
90
- print(f"Interaction {interaction.interaction_id}: {interaction.text_interaction}")
92
+ print(f"Interaction {interaction.interaction_id}: {interaction.content}")
91
93
 
92
94
  # Get interactions directly
93
95
  interactions_request = GetInteractionsRequest(
@@ -14,7 +14,7 @@ pip install agenticmem
14
14
  from agenticmem import AgenticMemClient
15
15
  from agenticmem_commons.api_schema.service_schemas import InteractionRequest
16
16
  from agenticmem_commons.api_schema.retriever_schema import (
17
- SearchInteractionRequest,
17
+ SearchInteractionRequest,
18
18
  SearchUserProfileRequest,
19
19
  GetInteractionsRequest,
20
20
  GetUserProfilesRequest
@@ -29,8 +29,8 @@ token = client.login(email="user@example.com", password="password123")
29
29
 
30
30
  # Publish a user interaction
31
31
  interaction = InteractionRequest(
32
- timestamp=int(datetime.utcnow().timestamp()),
33
- text_interaction="User clicked on product X",
32
+ created_at=int(datetime.utcnow().timestamp()),
33
+ content="User clicked on product X",
34
34
  user_action="click",
35
35
  user_action_description="Clicked on product details button"
36
36
  )
@@ -68,7 +68,7 @@ interactions_request = SearchInteractionRequest(
68
68
  )
69
69
  interactions = client.search_interactions(interactions_request)
70
70
  for interaction in interactions.interactions:
71
- print(f"Interaction {interaction.interaction_id}: {interaction.text_interaction}")
71
+ print(f"Interaction {interaction.interaction_id}: {interaction.content}")
72
72
 
73
73
  # Get interactions directly
74
74
  interactions_request = GetInteractionsRequest(
@@ -1,6 +1,7 @@
1
- import requests
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", "False") == "True":
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
- """Login to the AgenticMem API.
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._make_request(
144
+ response = await self._make_async_request(
126
145
  "POST",
127
146
  "/api/publish_interaction",
128
- data=request.model_dump_json(),
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._make_request(
165
+ response = await self._make_async_request(
147
166
  "POST",
148
167
  "/api/search_interactions",
149
- data=request.model_dump_json(),
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._make_request(
168
- "POST", "/api/search_profiles", data=request.model_dump_json()
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._make_request(
191
- "DELETE", "/api/delete_profile", data=request.model_dump_json()
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._make_request(
211
- "DELETE", "/api/delete_interaction", data=request.model_dump_json()
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._make_request("GET", "/api/profile_change_log")
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._make_request(
252
+ response = await self._make_async_request(
234
253
  "POST",
235
254
  "/api/get_interactions",
236
- data=request.model_dump_json(),
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._make_request(
273
+ response = await self._make_async_request(
255
274
  "POST",
256
275
  "/api/get_profiles",
257
- data=request.model_dump_json(),
276
+ json=request.model_dump(),
258
277
  )
259
278
  return GetUserProfilesResponse(**response)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "agenticmem"
3
- version = "0.1.1"
3
+ version = "0.1.2"
4
4
  description = "A Python client for the AgenticMem API"
5
5
  authors = ["AgenticMem Team"]
6
6
  readme = "README.md"
@@ -12,7 +12,7 @@ python = "^3.10"
12
12
  requests = "^2.25.0"
13
13
  pydantic = "^2.0.0"
14
14
  python-dateutil = "^2.8.0"
15
- agenticmem-commons = "0.1.1"
15
+ agenticmem-commons = "0.1.2"
16
16
  mkdocstrings = {version = ">=0.18.0", extras = ["python"]}
17
17
  griffe = "0.48.0"
18
18