redis-agent-memory 0.0.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.
Files changed (102) hide show
  1. redis_agent_memory-0.0.2/PKG-INFO +666 -0
  2. redis_agent_memory-0.0.2/README-PYPI.md +647 -0
  3. redis_agent_memory-0.0.2/py.typed +1 -0
  4. redis_agent_memory-0.0.2/pyproject.toml +58 -0
  5. redis_agent_memory-0.0.2/src/redis_agent_memory/__init__.py +11 -0
  6. redis_agent_memory-0.0.2/src/redis_agent_memory/_hooks/__init__.py +6 -0
  7. redis_agent_memory-0.0.2/src/redis_agent_memory/_hooks/registration.py +13 -0
  8. redis_agent_memory-0.0.2/src/redis_agent_memory/_hooks/sdkhooks.py +77 -0
  9. redis_agent_memory-0.0.2/src/redis_agent_memory/_hooks/types.py +113 -0
  10. redis_agent_memory-0.0.2/src/redis_agent_memory/_version.py +15 -0
  11. redis_agent_memory-0.0.2/src/redis_agent_memory/basesdk.py +396 -0
  12. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/__init__.py +115 -0
  13. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/agentmemoryerror.py +31 -0
  14. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/apierror.py +41 -0
  15. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/authenticationerrorresponsecontent.py +43 -0
  16. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/badrequesterrorresponsecontent.py +45 -0
  17. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/faileddependencyerrorresponsecontent.py +43 -0
  18. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/forbiddenerrorresponsecontent.py +41 -0
  19. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/no_response_error.py +18 -0
  20. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/notfounderrorresponsecontent.py +41 -0
  21. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/notimplementederrorresponsecontent.py +43 -0
  22. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/payloadtoolargeerrorresponsecontent.py +43 -0
  23. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/responsevalidationerror.py +28 -0
  24. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/timeouterrorresponsecontent.py +41 -0
  25. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/toomanyrequestserrorresponsecontent.py +43 -0
  26. redis_agent_memory-0.0.2/src/redis_agent_memory/errors/unexpectederrorresponsecontent.py +41 -0
  27. redis_agent_memory-0.0.2/src/redis_agent_memory/httpclient.py +126 -0
  28. redis_agent_memory-0.0.2/src/redis_agent_memory/models/__init__.py +376 -0
  29. redis_agent_memory-0.0.2/src/redis_agent_memory/models/addsessioneventop.py +38 -0
  30. redis_agent_memory-0.0.2/src/redis_agent_memory/models/addsessioneventrequestcontent.py +78 -0
  31. redis_agent_memory-0.0.2/src/redis_agent_memory/models/addsessioneventresponsecontent.py +17 -0
  32. redis_agent_memory-0.0.2/src/redis_agent_memory/models/authenticationerrortype.py +9 -0
  33. redis_agent_memory-0.0.2/src/redis_agent_memory/models/badrequesterrortype.py +9 -0
  34. redis_agent_memory-0.0.2/src/redis_agent_memory/models/bulkcreatelongtermmemoriesop.py +38 -0
  35. redis_agent_memory-0.0.2/src/redis_agent_memory/models/bulkcreatelongtermmemoriesrequestcontent.py +18 -0
  36. redis_agent_memory-0.0.2/src/redis_agent_memory/models/bulkcreatelongtermmemoriesresponsecontent.py +40 -0
  37. redis_agent_memory-0.0.2/src/redis_agent_memory/models/bulkdeletelongtermmemoriesop.py +38 -0
  38. redis_agent_memory-0.0.2/src/redis_agent_memory/models/bulkdeletelongtermmemoriesrequestcontent.py +24 -0
  39. redis_agent_memory-0.0.2/src/redis_agent_memory/models/bulkdeletelongtermmemoriesresponsecontent.py +40 -0
  40. redis_agent_memory-0.0.2/src/redis_agent_memory/models/bulkoperationerror.py +25 -0
  41. redis_agent_memory-0.0.2/src/redis_agent_memory/models/content.py +24 -0
  42. redis_agent_memory-0.0.2/src/redis_agent_memory/models/creatememoryrecord.py +90 -0
  43. redis_agent_memory-0.0.2/src/redis_agent_memory/models/deletesessioneventop.py +61 -0
  44. redis_agent_memory-0.0.2/src/redis_agent_memory/models/deletesessionmemoryop.py +52 -0
  45. redis_agent_memory-0.0.2/src/redis_agent_memory/models/faileddependencyerrortype.py +11 -0
  46. redis_agent_memory-0.0.2/src/redis_agent_memory/models/fielderror.py +20 -0
  47. redis_agent_memory-0.0.2/src/redis_agent_memory/models/filterconjunction.py +12 -0
  48. redis_agent_memory-0.0.2/src/redis_agent_memory/models/forbiddenerrortype.py +9 -0
  49. redis_agent_memory-0.0.2/src/redis_agent_memory/models/getlongtermmemoryop.py +52 -0
  50. redis_agent_memory-0.0.2/src/redis_agent_memory/models/getlongtermmemoryresponsecontent.py +100 -0
  51. redis_agent_memory-0.0.2/src/redis_agent_memory/models/getsessioneventop.py +61 -0
  52. redis_agent_memory-0.0.2/src/redis_agent_memory/models/getsessioneventresponsecontent.py +17 -0
  53. redis_agent_memory-0.0.2/src/redis_agent_memory/models/getsessionmemoryop.py +52 -0
  54. redis_agent_memory-0.0.2/src/redis_agent_memory/models/getsessionmemoryresponsecontent.py +39 -0
  55. redis_agent_memory-0.0.2/src/redis_agent_memory/models/healthresponsecontent.py +20 -0
  56. redis_agent_memory-0.0.2/src/redis_agent_memory/models/internal/__init__.py +26 -0
  57. redis_agent_memory-0.0.2/src/redis_agent_memory/models/internal/globals.py +38 -0
  58. redis_agent_memory-0.0.2/src/redis_agent_memory/models/listsessionsop.py +79 -0
  59. redis_agent_memory-0.0.2/src/redis_agent_memory/models/listsessionsresponsecontent.py +22 -0
  60. redis_agent_memory-0.0.2/src/redis_agent_memory/models/longtermmemoryfilter.py +78 -0
  61. redis_agent_memory-0.0.2/src/redis_agent_memory/models/memoryrecord.py +100 -0
  62. redis_agent_memory-0.0.2/src/redis_agent_memory/models/memorytype.py +14 -0
  63. redis_agent_memory-0.0.2/src/redis_agent_memory/models/messagerole.py +14 -0
  64. redis_agent_memory-0.0.2/src/redis_agent_memory/models/notfounderrortype.py +9 -0
  65. redis_agent_memory-0.0.2/src/redis_agent_memory/models/notimplementederrortype.py +9 -0
  66. redis_agent_memory-0.0.2/src/redis_agent_memory/models/numericfilter.py +58 -0
  67. redis_agent_memory-0.0.2/src/redis_agent_memory/models/payloadtoolargeerrortype.py +9 -0
  68. redis_agent_memory-0.0.2/src/redis_agent_memory/models/searchlongtermmemoryop.py +38 -0
  69. redis_agent_memory-0.0.2/src/redis_agent_memory/models/searchlongtermmemoryrequestcontent.py +76 -0
  70. redis_agent_memory-0.0.2/src/redis_agent_memory/models/searchlongtermmemoryresponsecontent.py +49 -0
  71. redis_agent_memory-0.0.2/src/redis_agent_memory/models/security.py +43 -0
  72. redis_agent_memory-0.0.2/src/redis_agent_memory/models/sessionevent.py +87 -0
  73. redis_agent_memory-0.0.2/src/redis_agent_memory/models/tagfilter.py +60 -0
  74. redis_agent_memory-0.0.2/src/redis_agent_memory/models/timeouterrortype.py +9 -0
  75. redis_agent_memory-0.0.2/src/redis_agent_memory/models/toomanyrequestserrortype.py +9 -0
  76. redis_agent_memory-0.0.2/src/redis_agent_memory/models/unexpectederrortype.py +9 -0
  77. redis_agent_memory-0.0.2/src/redis_agent_memory/models/updatelongtermmemoryop.py +78 -0
  78. redis_agent_memory-0.0.2/src/redis_agent_memory/models/updatelongtermmemoryrequestcontent.py +81 -0
  79. redis_agent_memory-0.0.2/src/redis_agent_memory/models/updatelongtermmemoryresponsecontent.py +100 -0
  80. redis_agent_memory-0.0.2/src/redis_agent_memory/py.typed +1 -0
  81. redis_agent_memory-0.0.2/src/redis_agent_memory/sdk.py +3889 -0
  82. redis_agent_memory-0.0.2/src/redis_agent_memory/sdkconfiguration.py +32 -0
  83. redis_agent_memory-0.0.2/src/redis_agent_memory/types/__init__.py +22 -0
  84. redis_agent_memory-0.0.2/src/redis_agent_memory/types/basemodel.py +78 -0
  85. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/__init__.py +179 -0
  86. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/annotations.py +80 -0
  87. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/datetimes.py +24 -0
  88. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/dynamic_imports.py +55 -0
  89. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/enums.py +135 -0
  90. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/eventstreaming.py +310 -0
  91. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/forms.py +235 -0
  92. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/headers.py +137 -0
  93. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/logger.py +28 -0
  94. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/metadata.py +120 -0
  95. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/queryparams.py +218 -0
  96. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/requestbodies.py +67 -0
  97. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/retries.py +272 -0
  98. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/security.py +216 -0
  99. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/serializers.py +226 -0
  100. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/unmarshal_json_response.py +39 -0
  101. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/url.py +156 -0
  102. redis_agent_memory-0.0.2/src/redis_agent_memory/utils/values.py +138 -0
@@ -0,0 +1,666 @@
1
+ Metadata-Version: 2.4
2
+ Name: redis-agent-memory
3
+ Version: 0.0.2
4
+ Summary: Python Client SDK for Redis Agent Memory Service
5
+ Author: Redis AI Services Team
6
+ Requires-Python: >=3.10
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3.14
13
+ Requires-Dist: httpcore (>=1.0.9)
14
+ Requires-Dist: httpx (>=0.28.1)
15
+ Requires-Dist: pydantic (>=2.11.2)
16
+ Project-URL: Repository, https://github.com/redis/langcache-sdks.git
17
+ Description-Content-Type: text/markdown
18
+
19
+ # redis-agent-memory
20
+
21
+ Developer-friendly & type-safe Python SDK specifically catered to leverage *redis-agent-memory* API.
22
+
23
+
24
+ <!-- Start Summary [summary] -->
25
+ ## Summary
26
+
27
+ MemoryDataPlaneServer: API for managing Agentic Memory Service (AMS) data plane operations.
28
+ <!-- End Summary [summary] -->
29
+
30
+ <!-- No Table of Contents [toc] -->
31
+
32
+ <!-- Start SDK Installation [installation] -->
33
+ ## SDK Installation
34
+
35
+ > [!NOTE]
36
+ > **Python version upgrade policy**
37
+ >
38
+ > Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
39
+
40
+ The SDK can be installed with *uv*, *pip*, or *poetry* package managers.
41
+
42
+ ### uv
43
+
44
+ *uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
45
+
46
+ ```bash
47
+ uv add redis-agent-memory
48
+ ```
49
+
50
+ ### PIP
51
+
52
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
53
+
54
+ ```bash
55
+ pip install redis-agent-memory
56
+ ```
57
+
58
+ ### Poetry
59
+
60
+ *Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
61
+
62
+ ```bash
63
+ poetry add redis-agent-memory
64
+ ```
65
+
66
+ ### Shell and script usage with `uv`
67
+
68
+ You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:
69
+
70
+ ```shell
71
+ uvx --from redis-agent-memory python
72
+ ```
73
+
74
+ It's also possible to write a standalone Python script without needing to set up a whole project like so:
75
+
76
+ ```python
77
+ #!/usr/bin/env -S uv run --script
78
+ # /// script
79
+ # requires-python = ">=3.10"
80
+ # dependencies = [
81
+ # "redis-agent-memory",
82
+ # ]
83
+ # ///
84
+
85
+ from redis_agent_memory import AgentMemory
86
+
87
+ sdk = AgentMemory(
88
+ # SDK arguments
89
+ )
90
+
91
+ # Rest of script here...
92
+ ```
93
+
94
+ Once that is saved to a file, you can run it with `uv run script.py` where
95
+ `script.py` can be replaced with the actual file name.
96
+ <!-- End SDK Installation [installation] -->
97
+
98
+ <!-- Start IDE Support [idesupport] -->
99
+ ## IDE Support
100
+
101
+ ### PyCharm
102
+
103
+ Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
104
+
105
+ - [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
106
+ <!-- End IDE Support [idesupport] -->
107
+
108
+ <!-- Start SDK Example Usage [usage] -->
109
+ ## SDK Example Usage
110
+
111
+ ### Add a session event
112
+
113
+ Append a chat turn to a session
114
+
115
+ ```python
116
+ # Synchronous Example
117
+ from redis_agent_memory import AgentMemory, models
118
+
119
+
120
+ with AgentMemory(
121
+ "https://api.example.com",
122
+ store_id="<id>",
123
+ api_key="<AGENT_MEMORY_API_KEY>",
124
+ ) as agent_memory:
125
+
126
+ res = agent_memory.add_session_event(actor_id="<id>", role=models.MessageRole.SYSTEM, content=[
127
+ {
128
+ "text": "<value>",
129
+ },
130
+ ], created_at=758464)
131
+
132
+ # Handle response
133
+ print(res)
134
+ ```
135
+
136
+ </br>
137
+
138
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
139
+
140
+ ```python
141
+ # Asynchronous Example
142
+ import asyncio
143
+ from redis_agent_memory import AgentMemory, models
144
+
145
+ async def main():
146
+
147
+ async with AgentMemory(
148
+ "https://api.example.com",
149
+ store_id="<id>",
150
+ api_key="<AGENT_MEMORY_API_KEY>",
151
+ ) as agent_memory:
152
+
153
+ res = await agent_memory.add_session_event_async(actor_id="<id>", role=models.MessageRole.SYSTEM, content=[
154
+ {
155
+ "text": "<value>",
156
+ },
157
+ ], created_at=758464)
158
+
159
+ # Handle response
160
+ print(res)
161
+
162
+ asyncio.run(main())
163
+ ```
164
+
165
+ ### Get session memory
166
+
167
+ Retrieve the conversation context for a session
168
+
169
+ ```python
170
+ # Synchronous Example
171
+ from redis_agent_memory import AgentMemory
172
+
173
+
174
+ with AgentMemory(
175
+ "https://api.example.com",
176
+ store_id="<id>",
177
+ api_key="<AGENT_MEMORY_API_KEY>",
178
+ ) as agent_memory:
179
+
180
+ res = agent_memory.get_session_memory(session_id="<id>")
181
+
182
+ # Handle response
183
+ print(res)
184
+ ```
185
+
186
+ </br>
187
+
188
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
189
+
190
+ ```python
191
+ # Asynchronous Example
192
+ import asyncio
193
+ from redis_agent_memory import AgentMemory
194
+
195
+ async def main():
196
+
197
+ async with AgentMemory(
198
+ "https://api.example.com",
199
+ store_id="<id>",
200
+ api_key="<AGENT_MEMORY_API_KEY>",
201
+ ) as agent_memory:
202
+
203
+ res = await agent_memory.get_session_memory_async(session_id="<id>")
204
+
205
+ # Handle response
206
+ print(res)
207
+
208
+ asyncio.run(main())
209
+ ```
210
+
211
+ ### Create long-term memories
212
+
213
+ Store facts and knowledge in bulk
214
+
215
+ ```python
216
+ # Synchronous Example
217
+ from redis_agent_memory import AgentMemory
218
+
219
+
220
+ with AgentMemory(
221
+ "https://api.example.com",
222
+ store_id="<id>",
223
+ api_key="<AGENT_MEMORY_API_KEY>",
224
+ ) as agent_memory:
225
+
226
+ res = agent_memory.bulk_create_long_term_memories(memories=[])
227
+
228
+ # Handle response
229
+ print(res)
230
+ ```
231
+
232
+ </br>
233
+
234
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
235
+
236
+ ```python
237
+ # Asynchronous Example
238
+ import asyncio
239
+ from redis_agent_memory import AgentMemory
240
+
241
+ async def main():
242
+
243
+ async with AgentMemory(
244
+ "https://api.example.com",
245
+ store_id="<id>",
246
+ api_key="<AGENT_MEMORY_API_KEY>",
247
+ ) as agent_memory:
248
+
249
+ res = await agent_memory.bulk_create_long_term_memories_async(memories=[])
250
+
251
+ # Handle response
252
+ print(res)
253
+
254
+ asyncio.run(main())
255
+ ```
256
+
257
+ ### Search long-term memory
258
+
259
+ Run a semantic search with optional filtering
260
+
261
+ ```python
262
+ # Synchronous Example
263
+ from redis_agent_memory import AgentMemory
264
+
265
+
266
+ with AgentMemory(
267
+ "https://api.example.com",
268
+ store_id="<id>",
269
+ api_key="<AGENT_MEMORY_API_KEY>",
270
+ ) as agent_memory:
271
+
272
+ res = agent_memory.search_long_term_memory()
273
+
274
+ # Handle response
275
+ print(res)
276
+ ```
277
+
278
+ </br>
279
+
280
+ The same SDK client can also be used to make asynchronous requests by importing asyncio.
281
+
282
+ ```python
283
+ # Asynchronous Example
284
+ import asyncio
285
+ from redis_agent_memory import AgentMemory
286
+
287
+ async def main():
288
+
289
+ async with AgentMemory(
290
+ "https://api.example.com",
291
+ store_id="<id>",
292
+ api_key="<AGENT_MEMORY_API_KEY>",
293
+ ) as agent_memory:
294
+
295
+ res = await agent_memory.search_long_term_memory_async()
296
+
297
+ # Handle response
298
+ print(res)
299
+
300
+ asyncio.run(main())
301
+ ```
302
+ <!-- End SDK Example Usage [usage] -->
303
+
304
+ <!-- Start Authentication [security] -->
305
+ ## Authentication
306
+
307
+ ### Per-Client Security Schemes
308
+
309
+ This SDK supports the following security scheme globally:
310
+
311
+ | Name | Type | Scheme | Environment Variable |
312
+ | --------- | ---- | ----------- | ---------------------- |
313
+ | `api_key` | http | HTTP Bearer | `AGENT_MEMORY_API_KEY` |
314
+
315
+ To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
316
+ ```python
317
+ from redis_agent_memory import AgentMemory
318
+
319
+
320
+ with AgentMemory(
321
+ "https://api.example.com",
322
+ api_key="<AGENT_MEMORY_API_KEY>",
323
+ ) as agent_memory:
324
+
325
+ res = agent_memory.health()
326
+
327
+ # Handle response
328
+ print(res)
329
+
330
+ ```
331
+ <!-- End Authentication [security] -->
332
+
333
+ <!-- Start Available Resources and Operations [operations] -->
334
+ ## Available Resources and Operations
335
+
336
+ <details open>
337
+ <summary>Available methods</summary>
338
+
339
+ ### [AgentMemory SDK](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md)
340
+
341
+ * [health](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#health) - Return information about the operational status of the service.
342
+ * [bulk_delete_long_term_memories](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#bulk_delete_long_term_memories) - Deletes long-term memories in bulk by their IDs.
343
+ * [bulk_create_long_term_memories](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#bulk_create_long_term_memories) - Creates long-term memories in bulk.
344
+ * [search_long_term_memory](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#search_long_term_memory) - Runs a semantic search on long-term memory with filtering options.
345
+ * [get_long_term_memory](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#get_long_term_memory) - Returns a long-term memory by its ID.
346
+ * [update_long_term_memory](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#update_long_term_memory) - Partially updates a long-term memory by its ID.
347
+ * [list_sessions](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#list_sessions) - Returns a paginated list of session IDs for a store.
348
+ * [add_session_event](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#add_session_event) - Appends a single event to a session. Creates the session if it does not exist. If sessionId is omitted, the server generates one.
349
+ * [delete_session_memory](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#delete_session_memory) - Deletes the session memory for a session.
350
+ * [get_session_memory](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#get_session_memory) - Returns the session memory for a session.
351
+ * [delete_session_event](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#delete_session_event) - Deletes a single event from a session by event ID.
352
+ * [get_session_event](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/docs/sdks/agentmemory/README.md#get_session_event) - Returns a single event from a session by event ID.
353
+
354
+ </details>
355
+ <!-- End Available Resources and Operations [operations] -->
356
+
357
+ <!-- Start Global Parameters [global-parameters] -->
358
+ ## Global Parameters
359
+
360
+ A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.
361
+
362
+ For example, you can set `storeId` to `"<id>"` at SDK initialization and then you do not have to pass the same value on calls to operations like `bulk_delete_long_term_memories`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
363
+
364
+
365
+ ### Available Globals
366
+
367
+ The following global parameter is available.
368
+ Global parameters can also be set via environment variable.
369
+
370
+ | Name | Type | Description | Environment |
371
+ | -------- | ---- | ----------------------- | --------------------- |
372
+ | store_id | str | The store_id parameter. | AGENT_MEMORY_STORE_ID |
373
+
374
+ ### Example
375
+
376
+ ```python
377
+ from redis_agent_memory import AgentMemory
378
+
379
+
380
+ with AgentMemory(
381
+ "https://api.example.com",
382
+ store_id="<id>",
383
+ api_key="<AGENT_MEMORY_API_KEY>",
384
+ ) as agent_memory:
385
+
386
+ res = agent_memory.bulk_delete_long_term_memories(memory_ids=[
387
+ "<value 1>",
388
+ "<value 2>",
389
+ "<value 3>",
390
+ ])
391
+
392
+ # Handle response
393
+ print(res)
394
+
395
+ ```
396
+ <!-- End Global Parameters [global-parameters] -->
397
+
398
+ <!-- Start Retries [retries] -->
399
+ ## Retries
400
+
401
+ Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
402
+
403
+ To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
404
+ ```python
405
+ from redis_agent_memory import AgentMemory
406
+ from redis_agent_memory.utils import BackoffStrategy, RetryConfig
407
+
408
+
409
+ with AgentMemory(
410
+ "https://api.example.com",
411
+ api_key="<AGENT_MEMORY_API_KEY>",
412
+ ) as agent_memory:
413
+
414
+ res = agent_memory.health(,
415
+ RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
416
+
417
+ # Handle response
418
+ print(res)
419
+
420
+ ```
421
+
422
+ If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
423
+ ```python
424
+ from redis_agent_memory import AgentMemory
425
+ from redis_agent_memory.utils import BackoffStrategy, RetryConfig
426
+
427
+
428
+ with AgentMemory(
429
+ "https://api.example.com",
430
+ retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
431
+ api_key="<AGENT_MEMORY_API_KEY>",
432
+ ) as agent_memory:
433
+
434
+ res = agent_memory.health()
435
+
436
+ # Handle response
437
+ print(res)
438
+
439
+ ```
440
+ <!-- End Retries [retries] -->
441
+
442
+ <!-- Start Error Handling [errors] -->
443
+ ## Error Handling
444
+
445
+ [`AgentMemoryError`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/agentmemoryerror.py) is the base class for all HTTP error responses. It has the following properties:
446
+
447
+ | Property | Type | Description |
448
+ | ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
449
+ | `err.message` | `str` | Error message |
450
+ | `err.status_code` | `int` | HTTP response status code eg `404` |
451
+ | `err.headers` | `httpx.Headers` | HTTP response headers |
452
+ | `err.body` | `str` | HTTP body. Can be empty string if no body is returned. |
453
+ | `err.raw_response` | `httpx.Response` | Raw HTTP response |
454
+ | `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/#error-classes). |
455
+
456
+ ### Example
457
+ ```python
458
+ from redis_agent_memory import AgentMemory, errors
459
+
460
+
461
+ with AgentMemory(
462
+ "https://api.example.com",
463
+ api_key="<AGENT_MEMORY_API_KEY>",
464
+ ) as agent_memory:
465
+ res = None
466
+ try:
467
+
468
+ res = agent_memory.health()
469
+
470
+ # Handle response
471
+ print(res)
472
+
473
+
474
+ except errors.AgentMemoryError as e:
475
+ # The base class for HTTP error responses
476
+ print(e.message)
477
+ print(e.status_code)
478
+ print(e.body)
479
+ print(e.headers)
480
+ print(e.raw_response)
481
+
482
+ # Depending on the method different errors may be thrown
483
+ if isinstance(e, errors.BadRequestErrorResponseContent):
484
+ print(e.data.title) # str
485
+ print(e.data.status) # Optional[int]
486
+ print(e.data.detail) # Optional[str]
487
+ print(e.data.instance) # Optional[str]
488
+ print(e.data.type) # models.BadRequestErrorType
489
+ ```
490
+
491
+ ### Error Classes
492
+ **Primary errors:**
493
+ * [`AgentMemoryError`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/agentmemoryerror.py): The base class for HTTP error responses.
494
+ * [`BadRequestErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/badrequesterrorresponsecontent.py): BadRequestError 400 response. Status code `400`.
495
+ * [`AuthenticationErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/authenticationerrorresponsecontent.py): AuthenticationError 401 response. Status code `401`.
496
+ * [`ForbiddenErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/forbiddenerrorresponsecontent.py): ForbiddenError 403 response. Status code `403`.
497
+ * [`NotFoundErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/notfounderrorresponsecontent.py): NotFoundError 404 response. Status code `404`.
498
+ * [`TimeoutErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/timeouterrorresponsecontent.py): TimeoutError 408 response. Status code `408`.
499
+ * [`PayloadTooLargeErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/payloadtoolargeerrorresponsecontent.py): PayloadTooLargeError 413 response. Status code `413`.
500
+ * [`FailedDependencyErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/faileddependencyerrorresponsecontent.py): FailedDependencyError 424 response. Status code `424`.
501
+ * [`TooManyRequestsErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/toomanyrequestserrorresponsecontent.py): TooManyRequestsError 429 response. Status code `429`.
502
+ * [`UnexpectedErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/unexpectederrorresponsecontent.py): UnexpectedError 500 response. Status code `500`.
503
+ * [`NotImplementedErrorResponseContent`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/notimplementederrorresponsecontent.py): NotImplementedError 501 response. Status code `501`.
504
+
505
+ <details><summary>Less common errors (5)</summary>
506
+
507
+ <br />
508
+
509
+ **Network errors:**
510
+ * [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
511
+ * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
512
+ * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.
513
+
514
+
515
+ **Inherit from [`AgentMemoryError`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/agentmemoryerror.py)**:
516
+ * [`ResponseValidationError`](https://github.com/redis/langcache-sdks/blob/master/agent-memory-python-sdk/./src/redis_agent_memory/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.
517
+
518
+ </details>
519
+ <!-- End Error Handling [errors] -->
520
+
521
+ <!-- Start Custom HTTP Client [http-client] -->
522
+ ## Custom HTTP Client
523
+
524
+ The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
525
+ Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
526
+ This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
527
+
528
+ For example, you could specify a header for every request that this sdk makes as follows:
529
+ ```python
530
+ from redis_agent_memory import AgentMemory
531
+ import httpx
532
+
533
+ http_client = httpx.Client(headers={"x-custom-header": "someValue"})
534
+ s = AgentMemory(client=http_client)
535
+ ```
536
+
537
+ or you could wrap the client with your own custom logic:
538
+ ```python
539
+ from redis_agent_memory import AgentMemory
540
+ from redis_agent_memory.httpclient import AsyncHttpClient
541
+ import httpx
542
+
543
+ class CustomClient(AsyncHttpClient):
544
+ client: AsyncHttpClient
545
+
546
+ def __init__(self, client: AsyncHttpClient):
547
+ self.client = client
548
+
549
+ async def send(
550
+ self,
551
+ request: httpx.Request,
552
+ *,
553
+ stream: bool = False,
554
+ auth: Union[
555
+ httpx._types.AuthTypes, httpx._client.UseClientDefault, None
556
+ ] = httpx.USE_CLIENT_DEFAULT,
557
+ follow_redirects: Union[
558
+ bool, httpx._client.UseClientDefault
559
+ ] = httpx.USE_CLIENT_DEFAULT,
560
+ ) -> httpx.Response:
561
+ request.headers["Client-Level-Header"] = "added by client"
562
+
563
+ return await self.client.send(
564
+ request, stream=stream, auth=auth, follow_redirects=follow_redirects
565
+ )
566
+
567
+ def build_request(
568
+ self,
569
+ method: str,
570
+ url: httpx._types.URLTypes,
571
+ *,
572
+ content: Optional[httpx._types.RequestContent] = None,
573
+ data: Optional[httpx._types.RequestData] = None,
574
+ files: Optional[httpx._types.RequestFiles] = None,
575
+ json: Optional[Any] = None,
576
+ params: Optional[httpx._types.QueryParamTypes] = None,
577
+ headers: Optional[httpx._types.HeaderTypes] = None,
578
+ cookies: Optional[httpx._types.CookieTypes] = None,
579
+ timeout: Union[
580
+ httpx._types.TimeoutTypes, httpx._client.UseClientDefault
581
+ ] = httpx.USE_CLIENT_DEFAULT,
582
+ extensions: Optional[httpx._types.RequestExtensions] = None,
583
+ ) -> httpx.Request:
584
+ return self.client.build_request(
585
+ method,
586
+ url,
587
+ content=content,
588
+ data=data,
589
+ files=files,
590
+ json=json,
591
+ params=params,
592
+ headers=headers,
593
+ cookies=cookies,
594
+ timeout=timeout,
595
+ extensions=extensions,
596
+ )
597
+
598
+ s = AgentMemory(async_client=CustomClient(httpx.AsyncClient()))
599
+ ```
600
+ <!-- End Custom HTTP Client [http-client] -->
601
+
602
+ <!-- Start Resource Management [resource-management] -->
603
+ ## Resource Management
604
+
605
+ The `AgentMemory` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
606
+
607
+ [context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers
608
+
609
+ ```python
610
+ from redis_agent_memory import AgentMemory
611
+ def main():
612
+
613
+ with AgentMemory(
614
+ "https://api.example.com",
615
+ store_id="<id>",
616
+ api_key="<AGENT_MEMORY_API_KEY>",
617
+ ) as agent_memory:
618
+ # Rest of application here...
619
+
620
+
621
+ # Or when using async:
622
+ async def amain():
623
+
624
+ async with AgentMemory(
625
+ "https://api.example.com",
626
+ store_id="<id>",
627
+ api_key="<AGENT_MEMORY_API_KEY>",
628
+ ) as agent_memory:
629
+ # Rest of application here...
630
+ ```
631
+ <!-- End Resource Management [resource-management] -->
632
+
633
+ <!-- Start Debugging [debug] -->
634
+ ## Debugging
635
+
636
+ You can setup your SDK to emit debug logs for SDK requests and responses.
637
+
638
+ You can pass your own logger class directly into your SDK.
639
+ ```python
640
+ from redis_agent_memory import AgentMemory
641
+ import logging
642
+
643
+ logging.basicConfig(level=logging.DEBUG)
644
+ s = AgentMemory(server_url="https://example.com", debug_logger=logging.getLogger("redis_agent_memory"))
645
+ ```
646
+
647
+ You can also enable a default debug logger by setting an environment variable `AGENT_MEMORY_DEBUG` to true.
648
+ <!-- End Debugging [debug] -->
649
+
650
+ <!-- Placeholder for Future Speakeasy SDK Sections -->
651
+
652
+ # Development
653
+
654
+ ## Maturity
655
+
656
+ This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
657
+ to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
658
+ looking for the latest version.
659
+
660
+ ## Contributions
661
+
662
+ While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
663
+ We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
664
+
665
+
666
+