letta-client 0.1.19__py3-none-any.whl → 0.1.22__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 letta-client might be problematic. Click here for more details.

Files changed (34) hide show
  1. letta_client/__init__.py +10 -0
  2. letta_client/agents/__init__.py +2 -1
  3. letta_client/agents/archival_memory/client.py +218 -25
  4. letta_client/agents/client.py +350 -1637
  5. letta_client/agents/core_memory/client.py +424 -97
  6. letta_client/agents/memory_variables/client.py +2 -2
  7. letta_client/agents/messages/__init__.py +2 -2
  8. letta_client/agents/messages/client.py +29 -14
  9. letta_client/agents/messages/types/__init__.py +2 -1
  10. letta_client/agents/messages/types/message_update_content.py +6 -0
  11. letta_client/blocks/client.py +127 -0
  12. letta_client/client.py +0 -4
  13. letta_client/core/client_wrapper.py +1 -1
  14. letta_client/providers/client.py +6 -6
  15. letta_client/runs/client.py +30 -18
  16. letta_client/sources/files/client.py +6 -6
  17. letta_client/tag/client.py +6 -6
  18. letta_client/tools/client.py +6 -36
  19. letta_client/types/__init__.py +10 -0
  20. letta_client/types/assistant_message.py +2 -1
  21. letta_client/types/assistant_message_content.py +6 -0
  22. letta_client/types/llm_config.py +6 -0
  23. letta_client/types/message.py +3 -2
  24. letta_client/types/message_create.py +3 -2
  25. letta_client/types/message_create_content.py +6 -0
  26. letta_client/types/system_message.py +3 -2
  27. letta_client/types/system_message_content.py +6 -0
  28. letta_client/types/text_content.py +23 -0
  29. letta_client/types/tool_create.py +0 -5
  30. letta_client/types/user_message.py +3 -2
  31. letta_client/types/user_message_content.py +6 -0
  32. {letta_client-0.1.19.dist-info → letta_client-0.1.22.dist-info}/METADATA +2 -2
  33. {letta_client-0.1.19.dist-info → letta_client-0.1.22.dist-info}/RECORD +34 -28
  34. {letta_client-0.1.19.dist-info → letta_client-0.1.22.dist-info}/WHEEL +0 -0
@@ -1,20 +1,32 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from ...core.client_wrapper import SyncClientWrapper
4
3
  import typing
4
+ from ...core.client_wrapper import SyncClientWrapper
5
5
  from ...core.request_options import RequestOptions
6
+ from ...types.memory import Memory
6
7
  from ...core.jsonable_encoder import jsonable_encoder
8
+ from ...core.unchecked_base_model import construct_type
9
+ from ...errors.unprocessable_entity_error import UnprocessableEntityError
10
+ from ...types.http_validation_error import HttpValidationError
7
11
  from json.decoder import JSONDecodeError
8
12
  from ...core.api_error import ApiError
13
+ from ...types.block import Block
14
+ from ...types.agent_state import AgentState
9
15
  from ...core.client_wrapper import AsyncClientWrapper
10
16
 
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
11
20
 
12
21
  class CoreMemoryClient:
13
22
  def __init__(self, *, client_wrapper: SyncClientWrapper):
14
23
  self._client_wrapper = client_wrapper
15
24
 
16
- def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
25
+ def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
17
26
  """
27
+ Retrieve the memory state of a specific agent.
28
+ This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
29
+
18
30
  Parameters
19
31
  ----------
20
32
  agent_id : str
@@ -24,7 +36,8 @@ class CoreMemoryClient:
24
36
 
25
37
  Returns
26
38
  -------
27
- None
39
+ Memory
40
+ Successful Response
28
41
 
29
42
  Examples
30
43
  --------
@@ -38,30 +51,53 @@ class CoreMemoryClient:
38
51
  )
39
52
  """
40
53
  _response = self._client_wrapper.httpx_client.request(
41
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory",
54
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory",
42
55
  method="GET",
43
56
  request_options=request_options,
44
57
  )
45
58
  try:
46
59
  if 200 <= _response.status_code < 300:
47
- return
60
+ return typing.cast(
61
+ Memory,
62
+ construct_type(
63
+ type_=Memory, # type: ignore
64
+ object_=_response.json(),
65
+ ),
66
+ )
67
+ if _response.status_code == 422:
68
+ raise UnprocessableEntityError(
69
+ typing.cast(
70
+ HttpValidationError,
71
+ construct_type(
72
+ type_=HttpValidationError, # type: ignore
73
+ object_=_response.json(),
74
+ ),
75
+ )
76
+ )
48
77
  _response_json = _response.json()
49
78
  except JSONDecodeError:
50
79
  raise ApiError(status_code=_response.status_code, body=_response.text)
51
80
  raise ApiError(status_code=_response.status_code, body=_response_json)
52
81
 
53
- def list_blocks(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
82
+ def retrieve_block(
83
+ self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
84
+ ) -> Block:
54
85
  """
86
+ Retrieve a memory block from an agent.
87
+
55
88
  Parameters
56
89
  ----------
57
90
  agent_id : str
58
91
 
92
+ block_label : str
93
+
59
94
  request_options : typing.Optional[RequestOptions]
60
95
  Request-specific configuration.
61
96
 
62
97
  Returns
63
98
  -------
64
- None
99
+ Block
100
+ Successful Response
65
101
 
66
102
  Examples
67
103
  --------
@@ -70,39 +106,91 @@ class CoreMemoryClient:
70
106
  client = Letta(
71
107
  token="YOUR_TOKEN",
72
108
  )
73
- client.agents.core_memory.list_blocks(
109
+ client.agents.core_memory.retrieve_block(
74
110
  agent_id="agent_id",
111
+ block_label="block_label",
75
112
  )
76
113
  """
77
114
  _response = self._client_wrapper.httpx_client.request(
78
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
115
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
79
116
  method="GET",
80
117
  request_options=request_options,
81
118
  )
82
119
  try:
83
120
  if 200 <= _response.status_code < 300:
84
- return
121
+ return typing.cast(
122
+ Block,
123
+ construct_type(
124
+ type_=Block, # type: ignore
125
+ object_=_response.json(),
126
+ ),
127
+ )
128
+ if _response.status_code == 422:
129
+ raise UnprocessableEntityError(
130
+ typing.cast(
131
+ HttpValidationError,
132
+ construct_type(
133
+ type_=HttpValidationError, # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ )
137
+ )
85
138
  _response_json = _response.json()
86
139
  except JSONDecodeError:
87
140
  raise ApiError(status_code=_response.status_code, body=_response.text)
88
141
  raise ApiError(status_code=_response.status_code, body=_response_json)
89
142
 
90
- def attach_block(
91
- self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
92
- ) -> None:
143
+ def modify_block(
144
+ self,
145
+ agent_id: str,
146
+ block_label: str,
147
+ *,
148
+ value: typing.Optional[str] = OMIT,
149
+ limit: typing.Optional[int] = OMIT,
150
+ name: typing.Optional[str] = OMIT,
151
+ is_template: typing.Optional[bool] = OMIT,
152
+ label: typing.Optional[str] = OMIT,
153
+ description: typing.Optional[str] = OMIT,
154
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
155
+ request_options: typing.Optional[RequestOptions] = None,
156
+ ) -> Block:
93
157
  """
158
+ Updates a memory block of an agent.
159
+
94
160
  Parameters
95
161
  ----------
96
162
  agent_id : str
97
163
 
98
- block_id : str
164
+ block_label : str
165
+
166
+ value : typing.Optional[str]
167
+ Value of the block.
168
+
169
+ limit : typing.Optional[int]
170
+ Character limit of the block.
171
+
172
+ name : typing.Optional[str]
173
+ Name of the block if it is a template.
174
+
175
+ is_template : typing.Optional[bool]
176
+ Whether the block is a template (e.g. saved human/persona options).
177
+
178
+ label : typing.Optional[str]
179
+ Label of the block (e.g. 'human', 'persona') in the context window.
180
+
181
+ description : typing.Optional[str]
182
+ Description of the block.
183
+
184
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
185
+ Metadata of the block.
99
186
 
100
187
  request_options : typing.Optional[RequestOptions]
101
188
  Request-specific configuration.
102
189
 
103
190
  Returns
104
191
  -------
105
- None
192
+ Block
193
+ Successful Response
106
194
 
107
195
  Examples
108
196
  --------
@@ -111,40 +199,67 @@ class CoreMemoryClient:
111
199
  client = Letta(
112
200
  token="YOUR_TOKEN",
113
201
  )
114
- client.agents.core_memory.attach_block(
202
+ client.agents.core_memory.modify_block(
115
203
  agent_id="agent_id",
116
- block_id="block_id",
204
+ block_label="block_label",
117
205
  )
118
206
  """
119
207
  _response = self._client_wrapper.httpx_client.request(
120
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/attach/{jsonable_encoder(block_id)}",
208
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
121
209
  method="PATCH",
210
+ json={
211
+ "value": value,
212
+ "limit": limit,
213
+ "name": name,
214
+ "is_template": is_template,
215
+ "label": label,
216
+ "description": description,
217
+ "metadata": metadata,
218
+ },
122
219
  request_options=request_options,
220
+ omit=OMIT,
123
221
  )
124
222
  try:
125
223
  if 200 <= _response.status_code < 300:
126
- return
224
+ return typing.cast(
225
+ Block,
226
+ construct_type(
227
+ type_=Block, # type: ignore
228
+ object_=_response.json(),
229
+ ),
230
+ )
231
+ if _response.status_code == 422:
232
+ raise UnprocessableEntityError(
233
+ typing.cast(
234
+ HttpValidationError,
235
+ construct_type(
236
+ type_=HttpValidationError, # type: ignore
237
+ object_=_response.json(),
238
+ ),
239
+ )
240
+ )
127
241
  _response_json = _response.json()
128
242
  except JSONDecodeError:
129
243
  raise ApiError(status_code=_response.status_code, body=_response.text)
130
244
  raise ApiError(status_code=_response.status_code, body=_response_json)
131
245
 
132
- def detach_block(
133
- self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
134
- ) -> None:
246
+ def list_blocks(
247
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
248
+ ) -> typing.List[Block]:
135
249
  """
250
+ Retrieve the memory blocks of a specific agent.
251
+
136
252
  Parameters
137
253
  ----------
138
254
  agent_id : str
139
255
 
140
- block_id : str
141
-
142
256
  request_options : typing.Optional[RequestOptions]
143
257
  Request-specific configuration.
144
258
 
145
259
  Returns
146
260
  -------
147
- None
261
+ typing.List[Block]
262
+ Successful Response
148
263
 
149
264
  Examples
150
265
  --------
@@ -153,40 +268,58 @@ class CoreMemoryClient:
153
268
  client = Letta(
154
269
  token="YOUR_TOKEN",
155
270
  )
156
- client.agents.core_memory.detach_block(
271
+ client.agents.core_memory.list_blocks(
157
272
  agent_id="agent_id",
158
- block_id="block_id",
159
273
  )
160
274
  """
161
275
  _response = self._client_wrapper.httpx_client.request(
162
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/detach/{jsonable_encoder(block_id)}",
163
- method="PATCH",
276
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks",
277
+ method="GET",
164
278
  request_options=request_options,
165
279
  )
166
280
  try:
167
281
  if 200 <= _response.status_code < 300:
168
- return
282
+ return typing.cast(
283
+ typing.List[Block],
284
+ construct_type(
285
+ type_=typing.List[Block], # type: ignore
286
+ object_=_response.json(),
287
+ ),
288
+ )
289
+ if _response.status_code == 422:
290
+ raise UnprocessableEntityError(
291
+ typing.cast(
292
+ HttpValidationError,
293
+ construct_type(
294
+ type_=HttpValidationError, # type: ignore
295
+ object_=_response.json(),
296
+ ),
297
+ )
298
+ )
169
299
  _response_json = _response.json()
170
300
  except JSONDecodeError:
171
301
  raise ApiError(status_code=_response.status_code, body=_response.text)
172
302
  raise ApiError(status_code=_response.status_code, body=_response_json)
173
303
 
174
- def retrieve_block(
175
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
176
- ) -> None:
304
+ def attach_block(
305
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
306
+ ) -> AgentState:
177
307
  """
308
+ Attach a block to an agent.
309
+
178
310
  Parameters
179
311
  ----------
180
312
  agent_id : str
181
313
 
182
- block_label : str
314
+ block_id : str
183
315
 
184
316
  request_options : typing.Optional[RequestOptions]
185
317
  Request-specific configuration.
186
318
 
187
319
  Returns
188
320
  -------
189
- None
321
+ AgentState
322
+ Successful Response
190
323
 
191
324
  Examples
192
325
  --------
@@ -195,40 +328,59 @@ class CoreMemoryClient:
195
328
  client = Letta(
196
329
  token="YOUR_TOKEN",
197
330
  )
198
- client.agents.core_memory.retrieve_block(
331
+ client.agents.core_memory.attach_block(
199
332
  agent_id="agent_id",
200
- block_label="block_label",
333
+ block_id="block_id",
201
334
  )
202
335
  """
203
336
  _response = self._client_wrapper.httpx_client.request(
204
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
205
- method="GET",
337
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/attach/{jsonable_encoder(block_id)}",
338
+ method="PATCH",
206
339
  request_options=request_options,
207
340
  )
208
341
  try:
209
342
  if 200 <= _response.status_code < 300:
210
- return
343
+ return typing.cast(
344
+ AgentState,
345
+ construct_type(
346
+ type_=AgentState, # type: ignore
347
+ object_=_response.json(),
348
+ ),
349
+ )
350
+ if _response.status_code == 422:
351
+ raise UnprocessableEntityError(
352
+ typing.cast(
353
+ HttpValidationError,
354
+ construct_type(
355
+ type_=HttpValidationError, # type: ignore
356
+ object_=_response.json(),
357
+ ),
358
+ )
359
+ )
211
360
  _response_json = _response.json()
212
361
  except JSONDecodeError:
213
362
  raise ApiError(status_code=_response.status_code, body=_response.text)
214
363
  raise ApiError(status_code=_response.status_code, body=_response_json)
215
364
 
216
- def modify_block(
217
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
218
- ) -> None:
365
+ def detach_block(
366
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
367
+ ) -> AgentState:
219
368
  """
369
+ Detach a block from an agent.
370
+
220
371
  Parameters
221
372
  ----------
222
373
  agent_id : str
223
374
 
224
- block_label : str
375
+ block_id : str
225
376
 
226
377
  request_options : typing.Optional[RequestOptions]
227
378
  Request-specific configuration.
228
379
 
229
380
  Returns
230
381
  -------
231
- None
382
+ AgentState
383
+ Successful Response
232
384
 
233
385
  Examples
234
386
  --------
@@ -237,19 +389,35 @@ class CoreMemoryClient:
237
389
  client = Letta(
238
390
  token="YOUR_TOKEN",
239
391
  )
240
- client.agents.core_memory.modify_block(
392
+ client.agents.core_memory.detach_block(
241
393
  agent_id="agent_id",
242
- block_label="block_label",
394
+ block_id="block_id",
243
395
  )
244
396
  """
245
397
  _response = self._client_wrapper.httpx_client.request(
246
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
398
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/detach/{jsonable_encoder(block_id)}",
247
399
  method="PATCH",
248
400
  request_options=request_options,
249
401
  )
250
402
  try:
251
403
  if 200 <= _response.status_code < 300:
252
- return
404
+ return typing.cast(
405
+ AgentState,
406
+ construct_type(
407
+ type_=AgentState, # type: ignore
408
+ object_=_response.json(),
409
+ ),
410
+ )
411
+ if _response.status_code == 422:
412
+ raise UnprocessableEntityError(
413
+ typing.cast(
414
+ HttpValidationError,
415
+ construct_type(
416
+ type_=HttpValidationError, # type: ignore
417
+ object_=_response.json(),
418
+ ),
419
+ )
420
+ )
253
421
  _response_json = _response.json()
254
422
  except JSONDecodeError:
255
423
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -260,8 +428,11 @@ class AsyncCoreMemoryClient:
260
428
  def __init__(self, *, client_wrapper: AsyncClientWrapper):
261
429
  self._client_wrapper = client_wrapper
262
430
 
263
- async def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
431
+ async def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
264
432
  """
433
+ Retrieve the memory state of a specific agent.
434
+ This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
435
+
265
436
  Parameters
266
437
  ----------
267
438
  agent_id : str
@@ -271,7 +442,8 @@ class AsyncCoreMemoryClient:
271
442
 
272
443
  Returns
273
444
  -------
274
- None
445
+ Memory
446
+ Successful Response
275
447
 
276
448
  Examples
277
449
  --------
@@ -293,30 +465,53 @@ class AsyncCoreMemoryClient:
293
465
  asyncio.run(main())
294
466
  """
295
467
  _response = await self._client_wrapper.httpx_client.request(
296
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory",
468
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory",
297
469
  method="GET",
298
470
  request_options=request_options,
299
471
  )
300
472
  try:
301
473
  if 200 <= _response.status_code < 300:
302
- return
474
+ return typing.cast(
475
+ Memory,
476
+ construct_type(
477
+ type_=Memory, # type: ignore
478
+ object_=_response.json(),
479
+ ),
480
+ )
481
+ if _response.status_code == 422:
482
+ raise UnprocessableEntityError(
483
+ typing.cast(
484
+ HttpValidationError,
485
+ construct_type(
486
+ type_=HttpValidationError, # type: ignore
487
+ object_=_response.json(),
488
+ ),
489
+ )
490
+ )
303
491
  _response_json = _response.json()
304
492
  except JSONDecodeError:
305
493
  raise ApiError(status_code=_response.status_code, body=_response.text)
306
494
  raise ApiError(status_code=_response.status_code, body=_response_json)
307
495
 
308
- async def list_blocks(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
496
+ async def retrieve_block(
497
+ self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
498
+ ) -> Block:
309
499
  """
500
+ Retrieve a memory block from an agent.
501
+
310
502
  Parameters
311
503
  ----------
312
504
  agent_id : str
313
505
 
506
+ block_label : str
507
+
314
508
  request_options : typing.Optional[RequestOptions]
315
509
  Request-specific configuration.
316
510
 
317
511
  Returns
318
512
  -------
319
- None
513
+ Block
514
+ Successful Response
320
515
 
321
516
  Examples
322
517
  --------
@@ -330,42 +525,94 @@ class AsyncCoreMemoryClient:
330
525
 
331
526
 
332
527
  async def main() -> None:
333
- await client.agents.core_memory.list_blocks(
528
+ await client.agents.core_memory.retrieve_block(
334
529
  agent_id="agent_id",
530
+ block_label="block_label",
335
531
  )
336
532
 
337
533
 
338
534
  asyncio.run(main())
339
535
  """
340
536
  _response = await self._client_wrapper.httpx_client.request(
341
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
537
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
342
538
  method="GET",
343
539
  request_options=request_options,
344
540
  )
345
541
  try:
346
542
  if 200 <= _response.status_code < 300:
347
- return
543
+ return typing.cast(
544
+ Block,
545
+ construct_type(
546
+ type_=Block, # type: ignore
547
+ object_=_response.json(),
548
+ ),
549
+ )
550
+ if _response.status_code == 422:
551
+ raise UnprocessableEntityError(
552
+ typing.cast(
553
+ HttpValidationError,
554
+ construct_type(
555
+ type_=HttpValidationError, # type: ignore
556
+ object_=_response.json(),
557
+ ),
558
+ )
559
+ )
348
560
  _response_json = _response.json()
349
561
  except JSONDecodeError:
350
562
  raise ApiError(status_code=_response.status_code, body=_response.text)
351
563
  raise ApiError(status_code=_response.status_code, body=_response_json)
352
564
 
353
- async def attach_block(
354
- self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
355
- ) -> None:
565
+ async def modify_block(
566
+ self,
567
+ agent_id: str,
568
+ block_label: str,
569
+ *,
570
+ value: typing.Optional[str] = OMIT,
571
+ limit: typing.Optional[int] = OMIT,
572
+ name: typing.Optional[str] = OMIT,
573
+ is_template: typing.Optional[bool] = OMIT,
574
+ label: typing.Optional[str] = OMIT,
575
+ description: typing.Optional[str] = OMIT,
576
+ metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
577
+ request_options: typing.Optional[RequestOptions] = None,
578
+ ) -> Block:
356
579
  """
580
+ Updates a memory block of an agent.
581
+
357
582
  Parameters
358
583
  ----------
359
584
  agent_id : str
360
585
 
361
- block_id : str
586
+ block_label : str
587
+
588
+ value : typing.Optional[str]
589
+ Value of the block.
590
+
591
+ limit : typing.Optional[int]
592
+ Character limit of the block.
593
+
594
+ name : typing.Optional[str]
595
+ Name of the block if it is a template.
596
+
597
+ is_template : typing.Optional[bool]
598
+ Whether the block is a template (e.g. saved human/persona options).
599
+
600
+ label : typing.Optional[str]
601
+ Label of the block (e.g. 'human', 'persona') in the context window.
602
+
603
+ description : typing.Optional[str]
604
+ Description of the block.
605
+
606
+ metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
607
+ Metadata of the block.
362
608
 
363
609
  request_options : typing.Optional[RequestOptions]
364
610
  Request-specific configuration.
365
611
 
366
612
  Returns
367
613
  -------
368
- None
614
+ Block
615
+ Successful Response
369
616
 
370
617
  Examples
371
618
  --------
@@ -379,43 +626,70 @@ class AsyncCoreMemoryClient:
379
626
 
380
627
 
381
628
  async def main() -> None:
382
- await client.agents.core_memory.attach_block(
629
+ await client.agents.core_memory.modify_block(
383
630
  agent_id="agent_id",
384
- block_id="block_id",
631
+ block_label="block_label",
385
632
  )
386
633
 
387
634
 
388
635
  asyncio.run(main())
389
636
  """
390
637
  _response = await self._client_wrapper.httpx_client.request(
391
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/attach/{jsonable_encoder(block_id)}",
638
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
392
639
  method="PATCH",
640
+ json={
641
+ "value": value,
642
+ "limit": limit,
643
+ "name": name,
644
+ "is_template": is_template,
645
+ "label": label,
646
+ "description": description,
647
+ "metadata": metadata,
648
+ },
393
649
  request_options=request_options,
650
+ omit=OMIT,
394
651
  )
395
652
  try:
396
653
  if 200 <= _response.status_code < 300:
397
- return
654
+ return typing.cast(
655
+ Block,
656
+ construct_type(
657
+ type_=Block, # type: ignore
658
+ object_=_response.json(),
659
+ ),
660
+ )
661
+ if _response.status_code == 422:
662
+ raise UnprocessableEntityError(
663
+ typing.cast(
664
+ HttpValidationError,
665
+ construct_type(
666
+ type_=HttpValidationError, # type: ignore
667
+ object_=_response.json(),
668
+ ),
669
+ )
670
+ )
398
671
  _response_json = _response.json()
399
672
  except JSONDecodeError:
400
673
  raise ApiError(status_code=_response.status_code, body=_response.text)
401
674
  raise ApiError(status_code=_response.status_code, body=_response_json)
402
675
 
403
- async def detach_block(
404
- self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
405
- ) -> None:
676
+ async def list_blocks(
677
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
678
+ ) -> typing.List[Block]:
406
679
  """
680
+ Retrieve the memory blocks of a specific agent.
681
+
407
682
  Parameters
408
683
  ----------
409
684
  agent_id : str
410
685
 
411
- block_id : str
412
-
413
686
  request_options : typing.Optional[RequestOptions]
414
687
  Request-specific configuration.
415
688
 
416
689
  Returns
417
690
  -------
418
- None
691
+ typing.List[Block]
692
+ Successful Response
419
693
 
420
694
  Examples
421
695
  --------
@@ -429,43 +703,61 @@ class AsyncCoreMemoryClient:
429
703
 
430
704
 
431
705
  async def main() -> None:
432
- await client.agents.core_memory.detach_block(
706
+ await client.agents.core_memory.list_blocks(
433
707
  agent_id="agent_id",
434
- block_id="block_id",
435
708
  )
436
709
 
437
710
 
438
711
  asyncio.run(main())
439
712
  """
440
713
  _response = await self._client_wrapper.httpx_client.request(
441
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/detach/{jsonable_encoder(block_id)}",
442
- method="PATCH",
714
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks",
715
+ method="GET",
443
716
  request_options=request_options,
444
717
  )
445
718
  try:
446
719
  if 200 <= _response.status_code < 300:
447
- return
720
+ return typing.cast(
721
+ typing.List[Block],
722
+ construct_type(
723
+ type_=typing.List[Block], # type: ignore
724
+ object_=_response.json(),
725
+ ),
726
+ )
727
+ if _response.status_code == 422:
728
+ raise UnprocessableEntityError(
729
+ typing.cast(
730
+ HttpValidationError,
731
+ construct_type(
732
+ type_=HttpValidationError, # type: ignore
733
+ object_=_response.json(),
734
+ ),
735
+ )
736
+ )
448
737
  _response_json = _response.json()
449
738
  except JSONDecodeError:
450
739
  raise ApiError(status_code=_response.status_code, body=_response.text)
451
740
  raise ApiError(status_code=_response.status_code, body=_response_json)
452
741
 
453
- async def retrieve_block(
454
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
455
- ) -> None:
742
+ async def attach_block(
743
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
744
+ ) -> AgentState:
456
745
  """
746
+ Attach a block to an agent.
747
+
457
748
  Parameters
458
749
  ----------
459
750
  agent_id : str
460
751
 
461
- block_label : str
752
+ block_id : str
462
753
 
463
754
  request_options : typing.Optional[RequestOptions]
464
755
  Request-specific configuration.
465
756
 
466
757
  Returns
467
758
  -------
468
- None
759
+ AgentState
760
+ Successful Response
469
761
 
470
762
  Examples
471
763
  --------
@@ -479,43 +771,62 @@ class AsyncCoreMemoryClient:
479
771
 
480
772
 
481
773
  async def main() -> None:
482
- await client.agents.core_memory.retrieve_block(
774
+ await client.agents.core_memory.attach_block(
483
775
  agent_id="agent_id",
484
- block_label="block_label",
776
+ block_id="block_id",
485
777
  )
486
778
 
487
779
 
488
780
  asyncio.run(main())
489
781
  """
490
782
  _response = await self._client_wrapper.httpx_client.request(
491
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
492
- method="GET",
783
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/attach/{jsonable_encoder(block_id)}",
784
+ method="PATCH",
493
785
  request_options=request_options,
494
786
  )
495
787
  try:
496
788
  if 200 <= _response.status_code < 300:
497
- return
789
+ return typing.cast(
790
+ AgentState,
791
+ construct_type(
792
+ type_=AgentState, # type: ignore
793
+ object_=_response.json(),
794
+ ),
795
+ )
796
+ if _response.status_code == 422:
797
+ raise UnprocessableEntityError(
798
+ typing.cast(
799
+ HttpValidationError,
800
+ construct_type(
801
+ type_=HttpValidationError, # type: ignore
802
+ object_=_response.json(),
803
+ ),
804
+ )
805
+ )
498
806
  _response_json = _response.json()
499
807
  except JSONDecodeError:
500
808
  raise ApiError(status_code=_response.status_code, body=_response.text)
501
809
  raise ApiError(status_code=_response.status_code, body=_response_json)
502
810
 
503
- async def modify_block(
504
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
505
- ) -> None:
811
+ async def detach_block(
812
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
813
+ ) -> AgentState:
506
814
  """
815
+ Detach a block from an agent.
816
+
507
817
  Parameters
508
818
  ----------
509
819
  agent_id : str
510
820
 
511
- block_label : str
821
+ block_id : str
512
822
 
513
823
  request_options : typing.Optional[RequestOptions]
514
824
  Request-specific configuration.
515
825
 
516
826
  Returns
517
827
  -------
518
- None
828
+ AgentState
829
+ Successful Response
519
830
 
520
831
  Examples
521
832
  --------
@@ -529,22 +840,38 @@ class AsyncCoreMemoryClient:
529
840
 
530
841
 
531
842
  async def main() -> None:
532
- await client.agents.core_memory.modify_block(
843
+ await client.agents.core_memory.detach_block(
533
844
  agent_id="agent_id",
534
- block_label="block_label",
845
+ block_id="block_id",
535
846
  )
536
847
 
537
848
 
538
849
  asyncio.run(main())
539
850
  """
540
851
  _response = await self._client_wrapper.httpx_client.request(
541
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
852
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/detach/{jsonable_encoder(block_id)}",
542
853
  method="PATCH",
543
854
  request_options=request_options,
544
855
  )
545
856
  try:
546
857
  if 200 <= _response.status_code < 300:
547
- return
858
+ return typing.cast(
859
+ AgentState,
860
+ construct_type(
861
+ type_=AgentState, # type: ignore
862
+ object_=_response.json(),
863
+ ),
864
+ )
865
+ if _response.status_code == 422:
866
+ raise UnprocessableEntityError(
867
+ typing.cast(
868
+ HttpValidationError,
869
+ construct_type(
870
+ type_=HttpValidationError, # type: ignore
871
+ object_=_response.json(),
872
+ ),
873
+ )
874
+ )
548
875
  _response_json = _response.json()
549
876
  except JSONDecodeError:
550
877
  raise ApiError(status_code=_response.status_code, body=_response.text)