letta-client 0.1.17__py3-none-any.whl → 0.1.21__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 (107) hide show
  1. letta_client/__init__.py +44 -116
  2. letta_client/agents/__init__.py +18 -42
  3. letta_client/agents/archival_memory/client.py +6 -6
  4. letta_client/agents/client.py +28 -18
  5. letta_client/agents/context/client.py +6 -4
  6. letta_client/agents/core_memory/client.py +152 -227
  7. letta_client/agents/memory_variables/__init__.py +2 -2
  8. letta_client/agents/memory_variables/client.py +15 -15
  9. letta_client/agents/memory_variables/types/__init__.py +2 -2
  10. letta_client/agents/memory_variables/types/{memory_variables_get_response.py → memory_variables_list_response.py} +1 -1
  11. letta_client/agents/messages/__init__.py +2 -22
  12. letta_client/agents/messages/client.py +39 -40
  13. letta_client/agents/messages/types/__init__.py +3 -21
  14. letta_client/agents/messages/types/letta_streaming_response.py +16 -139
  15. letta_client/agents/messages/types/message_update_content.py +6 -0
  16. letta_client/agents/messages/types/messages_list_response.py +2 -2
  17. letta_client/agents/sources/client.py +266 -5
  18. letta_client/agents/tools/client.py +25 -27
  19. letta_client/agents/types/__init__.py +15 -25
  20. letta_client/agents/types/agents_search_request_search_item.py +10 -78
  21. letta_client/agents/types/{agents_search_request_search_item_order_by.py → agents_search_request_search_item_direction.py} +7 -6
  22. letta_client/agents/types/agents_search_request_search_item_direction_direction.py +5 -0
  23. letta_client/agents/types/agents_search_request_search_item_direction_value.py +5 -0
  24. letta_client/agents/types/{agents_search_request_search_item_name.py → agents_search_request_search_item_one.py} +5 -4
  25. letta_client/agents/types/agents_search_request_search_item_one_operator.py +5 -0
  26. letta_client/agents/types/{agents_search_request_search_item_tags.py → agents_search_request_search_item_two.py} +2 -1
  27. letta_client/agents/types/{agents_search_request_search_item_version.py → agents_search_request_search_item_zero.py} +3 -2
  28. letta_client/blocks/client.py +45 -166
  29. letta_client/client.py +3 -3
  30. letta_client/core/client_wrapper.py +1 -1
  31. letta_client/jobs/client.py +4 -4
  32. letta_client/providers/client.py +10 -10
  33. letta_client/runs/client.py +44 -30
  34. letta_client/sources/client.py +12 -288
  35. letta_client/sources/files/client.py +6 -6
  36. letta_client/tag/client.py +6 -6
  37. letta_client/tools/client.py +69 -75
  38. letta_client/types/__init__.py +31 -99
  39. letta_client/types/agent_state.py +3 -7
  40. letta_client/types/{letta_schemas_openai_chat_completion_response_tool_call.py → assistant_message.py} +6 -4
  41. letta_client/types/assistant_message_content.py +6 -0
  42. letta_client/types/block.py +2 -6
  43. letta_client/types/block_update.py +1 -5
  44. letta_client/types/{assistant_message_output.py → chat_completion_message_tool_call.py} +5 -5
  45. letta_client/types/context_window_overview.py +4 -6
  46. letta_client/types/create_block.py +1 -5
  47. letta_client/types/{function_call_output.py → function.py} +1 -1
  48. letta_client/types/{function_schema.py → function_definition.py} +2 -1
  49. letta_client/types/{function_call_input.py → function_tool.py} +5 -3
  50. letta_client/types/job.py +1 -5
  51. letta_client/types/letta_message_union.py +9 -121
  52. letta_client/types/letta_usage_statistics.py +1 -0
  53. letta_client/types/llm_config.py +6 -0
  54. letta_client/types/{letta_schemas_message_message.py → message.py} +7 -8
  55. letta_client/types/message_create.py +3 -2
  56. letta_client/types/message_create_content.py +6 -0
  57. letta_client/types/passage.py +1 -5
  58. letta_client/types/reasoning_message.py +2 -1
  59. letta_client/types/run.py +1 -5
  60. letta_client/types/source.py +2 -6
  61. letta_client/types/{system_message_output.py → system_message.py} +6 -4
  62. letta_client/types/system_message_content.py +6 -0
  63. letta_client/types/{create_assistant_file_request.py → text_content.py} +5 -4
  64. letta_client/types/{letta_schemas_tool_tool.py → tool.py} +1 -1
  65. letta_client/types/{letta_schemas_letta_message_tool_call.py → tool_call.py} +1 -1
  66. letta_client/types/tool_call_message.py +2 -1
  67. letta_client/types/tool_call_message_tool_call.py +2 -2
  68. letta_client/types/tool_return_message.py +2 -1
  69. letta_client/types/tool_type.py +2 -1
  70. letta_client/types/{user_message_output.py → user_message.py} +6 -4
  71. letta_client/types/user_message_content.py +6 -0
  72. {letta_client-0.1.17.dist-info → letta_client-0.1.21.dist-info}/METADATA +2 -2
  73. {letta_client-0.1.17.dist-info → letta_client-0.1.21.dist-info}/RECORD +74 -99
  74. letta_client/agents/types/agents_search_request_search_item_name_operator.py +0 -5
  75. letta_client/agents/types/agents_search_request_search_item_order_by_direction.py +0 -5
  76. letta_client/agents/types/agents_search_request_search_item_order_by_value.py +0 -5
  77. letta_client/types/assistant_file.py +0 -33
  78. letta_client/types/assistant_message_input.py +0 -23
  79. letta_client/types/chat_completion_request.py +0 -49
  80. letta_client/types/chat_completion_request_function_call.py +0 -6
  81. letta_client/types/chat_completion_request_messages_item.py +0 -11
  82. letta_client/types/chat_completion_request_stop.py +0 -5
  83. letta_client/types/chat_completion_request_tool_choice.py +0 -8
  84. letta_client/types/chat_completion_response.py +0 -32
  85. letta_client/types/choice.py +0 -25
  86. letta_client/types/create_assistant_request.py +0 -57
  87. letta_client/types/delete_assistant_file_response.py +0 -28
  88. letta_client/types/delete_assistant_response.py +0 -28
  89. letta_client/types/letta_schemas_openai_chat_completion_request_tool.py +0 -21
  90. letta_client/types/letta_schemas_openai_chat_completion_request_tool_call.py +0 -24
  91. letta_client/types/letta_schemas_openai_chat_completion_request_tool_call_function.py +0 -20
  92. letta_client/types/letta_schemas_openai_chat_completion_response_message.py +0 -24
  93. letta_client/types/letta_schemas_openai_chat_completions_tool_call_function.py +0 -27
  94. letta_client/types/letta_schemas_openai_chat_completions_tool_call_input.py +0 -29
  95. letta_client/types/letta_schemas_openai_chat_completions_tool_call_output.py +0 -29
  96. letta_client/types/log_prob_token.py +0 -21
  97. letta_client/types/message_content_log_prob.py +0 -23
  98. letta_client/types/open_ai_assistant.py +0 -67
  99. letta_client/types/response_format.py +0 -19
  100. letta_client/types/system_message_input.py +0 -21
  101. letta_client/types/tool_call_function_output.py +0 -27
  102. letta_client/types/tool_function_choice.py +0 -21
  103. letta_client/types/tool_input.py +0 -21
  104. letta_client/types/tool_message.py +0 -21
  105. letta_client/types/user_message_input.py +0 -22
  106. letta_client/types/user_message_input_content.py +0 -5
  107. {letta_client-0.1.17.dist-info → letta_client-0.1.21.dist-info}/WHEEL +0 -0
@@ -11,6 +11,7 @@ from ...types.http_validation_error import HttpValidationError
11
11
  from json.decoder import JSONDecodeError
12
12
  from ...core.api_error import ApiError
13
13
  from ...types.block import Block
14
+ from ...types.agent_state import AgentState
14
15
  from ...core.client_wrapper import AsyncClientWrapper
15
16
 
16
17
  # this is used as the default value for optional parameters
@@ -21,7 +22,7 @@ class CoreMemoryClient:
21
22
  def __init__(self, *, client_wrapper: SyncClientWrapper):
22
23
  self._client_wrapper = client_wrapper
23
24
 
24
- def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
25
+ def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
25
26
  """
26
27
  Retrieve the memory state of a specific agent.
27
28
  This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
@@ -45,12 +46,12 @@ class CoreMemoryClient:
45
46
  client = Letta(
46
47
  token="YOUR_TOKEN",
47
48
  )
48
- client.agents.core_memory.get(
49
+ client.agents.core_memory.retrieve(
49
50
  agent_id="agent_id",
50
51
  )
51
52
  """
52
53
  _response = self._client_wrapper.httpx_client.request(
53
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory",
54
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory",
54
55
  method="GET",
55
56
  request_options=request_options,
56
57
  )
@@ -78,7 +79,7 @@ class CoreMemoryClient:
78
79
  raise ApiError(status_code=_response.status_code, body=_response.text)
79
80
  raise ApiError(status_code=_response.status_code, body=_response_json)
80
81
 
81
- def get_block(
82
+ def retrieve_block(
82
83
  self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
83
84
  ) -> Block:
84
85
  """
@@ -105,13 +106,13 @@ class CoreMemoryClient:
105
106
  client = Letta(
106
107
  token="YOUR_TOKEN",
107
108
  )
108
- client.agents.core_memory.get_block(
109
+ client.agents.core_memory.retrieve_block(
109
110
  agent_id="agent_id",
110
111
  block_label="block_label",
111
112
  )
112
113
  """
113
114
  _response = self._client_wrapper.httpx_client.request(
114
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
115
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
115
116
  method="GET",
116
117
  request_options=request_options,
117
118
  )
@@ -139,68 +140,7 @@ class CoreMemoryClient:
139
140
  raise ApiError(status_code=_response.status_code, body=_response.text)
140
141
  raise ApiError(status_code=_response.status_code, body=_response_json)
141
142
 
142
- def remove_block(
143
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
144
- ) -> Memory:
145
- """
146
- Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
147
-
148
- Parameters
149
- ----------
150
- agent_id : str
151
-
152
- block_label : str
153
-
154
- request_options : typing.Optional[RequestOptions]
155
- Request-specific configuration.
156
-
157
- Returns
158
- -------
159
- Memory
160
- Successful Response
161
-
162
- Examples
163
- --------
164
- from letta_client import Letta
165
-
166
- client = Letta(
167
- token="YOUR_TOKEN",
168
- )
169
- client.agents.core_memory.remove_block(
170
- agent_id="agent_id",
171
- block_label="block_label",
172
- )
173
- """
174
- _response = self._client_wrapper.httpx_client.request(
175
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
176
- method="DELETE",
177
- request_options=request_options,
178
- )
179
- try:
180
- if 200 <= _response.status_code < 300:
181
- return typing.cast(
182
- Memory,
183
- construct_type(
184
- type_=Memory, # type: ignore
185
- object_=_response.json(),
186
- ),
187
- )
188
- if _response.status_code == 422:
189
- raise UnprocessableEntityError(
190
- typing.cast(
191
- HttpValidationError,
192
- construct_type(
193
- type_=HttpValidationError, # type: ignore
194
- object_=_response.json(),
195
- ),
196
- )
197
- )
198
- _response_json = _response.json()
199
- except JSONDecodeError:
200
- raise ApiError(status_code=_response.status_code, body=_response.text)
201
- raise ApiError(status_code=_response.status_code, body=_response_json)
202
-
203
- def update_block(
143
+ def modify_block(
204
144
  self,
205
145
  agent_id: str,
206
146
  block_label: str,
@@ -215,7 +155,7 @@ class CoreMemoryClient:
215
155
  request_options: typing.Optional[RequestOptions] = None,
216
156
  ) -> Block:
217
157
  """
218
- Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
158
+ Updates a memory block of an agent.
219
159
 
220
160
  Parameters
221
161
  ----------
@@ -259,13 +199,13 @@ class CoreMemoryClient:
259
199
  client = Letta(
260
200
  token="YOUR_TOKEN",
261
201
  )
262
- client.agents.core_memory.update_block(
202
+ client.agents.core_memory.modify_block(
263
203
  agent_id="agent_id",
264
204
  block_label="block_label",
265
205
  )
266
206
  """
267
207
  _response = self._client_wrapper.httpx_client.request(
268
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
208
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
269
209
  method="PATCH",
270
210
  json={
271
211
  "value": value,
@@ -274,7 +214,7 @@ class CoreMemoryClient:
274
214
  "is_template": is_template,
275
215
  "label": label,
276
216
  "description": description,
277
- "metadata_": metadata,
217
+ "metadata": metadata,
278
218
  },
279
219
  request_options=request_options,
280
220
  omit=OMIT,
@@ -303,7 +243,9 @@ class CoreMemoryClient:
303
243
  raise ApiError(status_code=_response.status_code, body=_response.text)
304
244
  raise ApiError(status_code=_response.status_code, body=_response_json)
305
245
 
306
- def list(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Block]:
246
+ def list_blocks(
247
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
248
+ ) -> typing.List[Block]:
307
249
  """
308
250
  Retrieve the memory blocks of a specific agent.
309
251
 
@@ -326,12 +268,12 @@ class CoreMemoryClient:
326
268
  client = Letta(
327
269
  token="YOUR_TOKEN",
328
270
  )
329
- client.agents.core_memory.list(
271
+ client.agents.core_memory.list_blocks(
330
272
  agent_id="agent_id",
331
273
  )
332
274
  """
333
275
  _response = self._client_wrapper.httpx_client.request(
334
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
276
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks",
335
277
  method="GET",
336
278
  request_options=request_options,
337
279
  )
@@ -359,52 +301,24 @@ class CoreMemoryClient:
359
301
  raise ApiError(status_code=_response.status_code, body=_response.text)
360
302
  raise ApiError(status_code=_response.status_code, body=_response_json)
361
303
 
362
- def add_block(
363
- self,
364
- agent_id: str,
365
- *,
366
- value: str,
367
- label: str,
368
- limit: typing.Optional[int] = OMIT,
369
- name: typing.Optional[str] = OMIT,
370
- is_template: typing.Optional[bool] = OMIT,
371
- description: typing.Optional[str] = OMIT,
372
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
373
- request_options: typing.Optional[RequestOptions] = None,
374
- ) -> Memory:
304
+ def attach_block(
305
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
306
+ ) -> AgentState:
375
307
  """
376
- Creates a memory block and links it to the agent.
308
+ Attach a block to an agent.
377
309
 
378
310
  Parameters
379
311
  ----------
380
312
  agent_id : str
381
313
 
382
- value : str
383
- Value of the block.
384
-
385
- label : str
386
- Label of the block.
387
-
388
- limit : typing.Optional[int]
389
- Character limit of the block.
390
-
391
- name : typing.Optional[str]
392
- Name of the block if it is a template.
393
-
394
- is_template : typing.Optional[bool]
395
-
396
- description : typing.Optional[str]
397
- Description of the block.
398
-
399
- metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
400
- Metadata of the block.
314
+ block_id : str
401
315
 
402
316
  request_options : typing.Optional[RequestOptions]
403
317
  Request-specific configuration.
404
318
 
405
319
  Returns
406
320
  -------
407
- Memory
321
+ AgentState
408
322
  Successful Response
409
323
 
410
324
  Examples
@@ -414,33 +328,22 @@ class CoreMemoryClient:
414
328
  client = Letta(
415
329
  token="YOUR_TOKEN",
416
330
  )
417
- client.agents.core_memory.add_block(
331
+ client.agents.core_memory.attach_block(
418
332
  agent_id="agent_id",
419
- value="value",
420
- label="label",
333
+ block_id="block_id",
421
334
  )
422
335
  """
423
336
  _response = self._client_wrapper.httpx_client.request(
424
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
425
- method="POST",
426
- json={
427
- "value": value,
428
- "limit": limit,
429
- "name": name,
430
- "is_template": is_template,
431
- "label": label,
432
- "description": description,
433
- "metadata_": metadata,
434
- },
337
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/attach/{jsonable_encoder(block_id)}",
338
+ method="PATCH",
435
339
  request_options=request_options,
436
- omit=OMIT,
437
340
  )
438
341
  try:
439
342
  if 200 <= _response.status_code < 300:
440
343
  return typing.cast(
441
- Memory,
344
+ AgentState,
442
345
  construct_type(
443
- type_=Memory, # type: ignore
346
+ type_=AgentState, # type: ignore
444
347
  object_=_response.json(),
445
348
  ),
446
349
  )
@@ -459,58 +362,49 @@ class CoreMemoryClient:
459
362
  raise ApiError(status_code=_response.status_code, body=_response.text)
460
363
  raise ApiError(status_code=_response.status_code, body=_response_json)
461
364
 
462
-
463
- class AsyncCoreMemoryClient:
464
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
465
- self._client_wrapper = client_wrapper
466
-
467
- async def get(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
365
+ def detach_block(
366
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
367
+ ) -> AgentState:
468
368
  """
469
- Retrieve the memory state of a specific agent.
470
- This endpoint fetches the current memory state of the agent identified by the user ID and agent ID.
369
+ Detach a block from an agent.
471
370
 
472
371
  Parameters
473
372
  ----------
474
373
  agent_id : str
475
374
 
375
+ block_id : str
376
+
476
377
  request_options : typing.Optional[RequestOptions]
477
378
  Request-specific configuration.
478
379
 
479
380
  Returns
480
381
  -------
481
- Memory
382
+ AgentState
482
383
  Successful Response
483
384
 
484
385
  Examples
485
386
  --------
486
- import asyncio
487
-
488
- from letta_client import AsyncLetta
387
+ from letta_client import Letta
489
388
 
490
- client = AsyncLetta(
389
+ client = Letta(
491
390
  token="YOUR_TOKEN",
492
391
  )
493
-
494
-
495
- async def main() -> None:
496
- await client.agents.core_memory.get(
497
- agent_id="agent_id",
498
- )
499
-
500
-
501
- asyncio.run(main())
392
+ client.agents.core_memory.detach_block(
393
+ agent_id="agent_id",
394
+ block_id="block_id",
395
+ )
502
396
  """
503
- _response = await self._client_wrapper.httpx_client.request(
504
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory",
505
- method="GET",
397
+ _response = self._client_wrapper.httpx_client.request(
398
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/detach/{jsonable_encoder(block_id)}",
399
+ method="PATCH",
506
400
  request_options=request_options,
507
401
  )
508
402
  try:
509
403
  if 200 <= _response.status_code < 300:
510
404
  return typing.cast(
511
- Memory,
405
+ AgentState,
512
406
  construct_type(
513
- type_=Memory, # type: ignore
407
+ type_=AgentState, # type: ignore
514
408
  object_=_response.json(),
515
409
  ),
516
410
  )
@@ -529,24 +423,26 @@ class AsyncCoreMemoryClient:
529
423
  raise ApiError(status_code=_response.status_code, body=_response.text)
530
424
  raise ApiError(status_code=_response.status_code, body=_response_json)
531
425
 
532
- async def get_block(
533
- self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
534
- ) -> Block:
426
+
427
+ class AsyncCoreMemoryClient:
428
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
429
+ self._client_wrapper = client_wrapper
430
+
431
+ async def retrieve(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Memory:
535
432
  """
536
- Retrieve a memory block from an agent.
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.
537
435
 
538
436
  Parameters
539
437
  ----------
540
438
  agent_id : str
541
439
 
542
- block_label : str
543
-
544
440
  request_options : typing.Optional[RequestOptions]
545
441
  Request-specific configuration.
546
442
 
547
443
  Returns
548
444
  -------
549
- Block
445
+ Memory
550
446
  Successful Response
551
447
 
552
448
  Examples
@@ -561,25 +457,24 @@ class AsyncCoreMemoryClient:
561
457
 
562
458
 
563
459
  async def main() -> None:
564
- await client.agents.core_memory.get_block(
460
+ await client.agents.core_memory.retrieve(
565
461
  agent_id="agent_id",
566
- block_label="block_label",
567
462
  )
568
463
 
569
464
 
570
465
  asyncio.run(main())
571
466
  """
572
467
  _response = await self._client_wrapper.httpx_client.request(
573
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
468
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory",
574
469
  method="GET",
575
470
  request_options=request_options,
576
471
  )
577
472
  try:
578
473
  if 200 <= _response.status_code < 300:
579
474
  return typing.cast(
580
- Block,
475
+ Memory,
581
476
  construct_type(
582
- type_=Block, # type: ignore
477
+ type_=Memory, # type: ignore
583
478
  object_=_response.json(),
584
479
  ),
585
480
  )
@@ -598,11 +493,11 @@ class AsyncCoreMemoryClient:
598
493
  raise ApiError(status_code=_response.status_code, body=_response.text)
599
494
  raise ApiError(status_code=_response.status_code, body=_response_json)
600
495
 
601
- async def remove_block(
496
+ async def retrieve_block(
602
497
  self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
603
- ) -> Memory:
498
+ ) -> Block:
604
499
  """
605
- Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
500
+ Retrieve a memory block from an agent.
606
501
 
607
502
  Parameters
608
503
  ----------
@@ -615,7 +510,7 @@ class AsyncCoreMemoryClient:
615
510
 
616
511
  Returns
617
512
  -------
618
- Memory
513
+ Block
619
514
  Successful Response
620
515
 
621
516
  Examples
@@ -630,7 +525,7 @@ class AsyncCoreMemoryClient:
630
525
 
631
526
 
632
527
  async def main() -> None:
633
- await client.agents.core_memory.remove_block(
528
+ await client.agents.core_memory.retrieve_block(
634
529
  agent_id="agent_id",
635
530
  block_label="block_label",
636
531
  )
@@ -639,16 +534,16 @@ class AsyncCoreMemoryClient:
639
534
  asyncio.run(main())
640
535
  """
641
536
  _response = await self._client_wrapper.httpx_client.request(
642
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
643
- method="DELETE",
537
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
538
+ method="GET",
644
539
  request_options=request_options,
645
540
  )
646
541
  try:
647
542
  if 200 <= _response.status_code < 300:
648
543
  return typing.cast(
649
- Memory,
544
+ Block,
650
545
  construct_type(
651
- type_=Memory, # type: ignore
546
+ type_=Block, # type: ignore
652
547
  object_=_response.json(),
653
548
  ),
654
549
  )
@@ -667,7 +562,7 @@ class AsyncCoreMemoryClient:
667
562
  raise ApiError(status_code=_response.status_code, body=_response.text)
668
563
  raise ApiError(status_code=_response.status_code, body=_response_json)
669
564
 
670
- async def update_block(
565
+ async def modify_block(
671
566
  self,
672
567
  agent_id: str,
673
568
  block_label: str,
@@ -682,7 +577,7 @@ class AsyncCoreMemoryClient:
682
577
  request_options: typing.Optional[RequestOptions] = None,
683
578
  ) -> Block:
684
579
  """
685
- Removes a memory block from an agent by unlnking it. If the block is not linked to any other agent, it is deleted.
580
+ Updates a memory block of an agent.
686
581
 
687
582
  Parameters
688
583
  ----------
@@ -731,7 +626,7 @@ class AsyncCoreMemoryClient:
731
626
 
732
627
 
733
628
  async def main() -> None:
734
- await client.agents.core_memory.update_block(
629
+ await client.agents.core_memory.modify_block(
735
630
  agent_id="agent_id",
736
631
  block_label="block_label",
737
632
  )
@@ -740,7 +635,7 @@ class AsyncCoreMemoryClient:
740
635
  asyncio.run(main())
741
636
  """
742
637
  _response = await self._client_wrapper.httpx_client.request(
743
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks/{jsonable_encoder(block_label)}",
638
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
744
639
  method="PATCH",
745
640
  json={
746
641
  "value": value,
@@ -749,7 +644,7 @@ class AsyncCoreMemoryClient:
749
644
  "is_template": is_template,
750
645
  "label": label,
751
646
  "description": description,
752
- "metadata_": metadata,
647
+ "metadata": metadata,
753
648
  },
754
649
  request_options=request_options,
755
650
  omit=OMIT,
@@ -778,7 +673,7 @@ class AsyncCoreMemoryClient:
778
673
  raise ApiError(status_code=_response.status_code, body=_response.text)
779
674
  raise ApiError(status_code=_response.status_code, body=_response_json)
780
675
 
781
- async def list(
676
+ async def list_blocks(
782
677
  self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
783
678
  ) -> typing.List[Block]:
784
679
  """
@@ -808,7 +703,7 @@ class AsyncCoreMemoryClient:
808
703
 
809
704
 
810
705
  async def main() -> None:
811
- await client.agents.core_memory.list(
706
+ await client.agents.core_memory.list_blocks(
812
707
  agent_id="agent_id",
813
708
  )
814
709
 
@@ -816,7 +711,7 @@ class AsyncCoreMemoryClient:
816
711
  asyncio.run(main())
817
712
  """
818
713
  _response = await self._client_wrapper.httpx_client.request(
819
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
714
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks",
820
715
  method="GET",
821
716
  request_options=request_options,
822
717
  )
@@ -844,52 +739,93 @@ class AsyncCoreMemoryClient:
844
739
  raise ApiError(status_code=_response.status_code, body=_response.text)
845
740
  raise ApiError(status_code=_response.status_code, body=_response_json)
846
741
 
847
- async def add_block(
848
- self,
849
- agent_id: str,
850
- *,
851
- value: str,
852
- label: str,
853
- limit: typing.Optional[int] = OMIT,
854
- name: typing.Optional[str] = OMIT,
855
- is_template: typing.Optional[bool] = OMIT,
856
- description: typing.Optional[str] = OMIT,
857
- metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
858
- request_options: typing.Optional[RequestOptions] = None,
859
- ) -> Memory:
742
+ async def attach_block(
743
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
744
+ ) -> AgentState:
860
745
  """
861
- Creates a memory block and links it to the agent.
746
+ Attach a block to an agent.
862
747
 
863
748
  Parameters
864
749
  ----------
865
750
  agent_id : str
866
751
 
867
- value : str
868
- Value of the block.
752
+ block_id : str
869
753
 
870
- label : str
871
- Label of the block.
754
+ request_options : typing.Optional[RequestOptions]
755
+ Request-specific configuration.
872
756
 
873
- limit : typing.Optional[int]
874
- Character limit of the block.
757
+ Returns
758
+ -------
759
+ AgentState
760
+ Successful Response
875
761
 
876
- name : typing.Optional[str]
877
- Name of the block if it is a template.
762
+ Examples
763
+ --------
764
+ import asyncio
878
765
 
879
- is_template : typing.Optional[bool]
766
+ from letta_client import AsyncLetta
880
767
 
881
- description : typing.Optional[str]
882
- Description of the block.
768
+ client = AsyncLetta(
769
+ token="YOUR_TOKEN",
770
+ )
883
771
 
884
- metadata : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
885
- Metadata of the block.
772
+
773
+ async def main() -> None:
774
+ await client.agents.core_memory.attach_block(
775
+ agent_id="agent_id",
776
+ block_id="block_id",
777
+ )
778
+
779
+
780
+ asyncio.run(main())
781
+ """
782
+ _response = await self._client_wrapper.httpx_client.request(
783
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/attach/{jsonable_encoder(block_id)}",
784
+ method="PATCH",
785
+ request_options=request_options,
786
+ )
787
+ try:
788
+ if 200 <= _response.status_code < 300:
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
+ )
806
+ _response_json = _response.json()
807
+ except JSONDecodeError:
808
+ raise ApiError(status_code=_response.status_code, body=_response.text)
809
+ raise ApiError(status_code=_response.status_code, body=_response_json)
810
+
811
+ async def detach_block(
812
+ self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
813
+ ) -> AgentState:
814
+ """
815
+ Detach a block from an agent.
816
+
817
+ Parameters
818
+ ----------
819
+ agent_id : str
820
+
821
+ block_id : str
886
822
 
887
823
  request_options : typing.Optional[RequestOptions]
888
824
  Request-specific configuration.
889
825
 
890
826
  Returns
891
827
  -------
892
- Memory
828
+ AgentState
893
829
  Successful Response
894
830
 
895
831
  Examples
@@ -904,36 +840,25 @@ class AsyncCoreMemoryClient:
904
840
 
905
841
 
906
842
  async def main() -> None:
907
- await client.agents.core_memory.add_block(
843
+ await client.agents.core_memory.detach_block(
908
844
  agent_id="agent_id",
909
- value="value",
910
- label="label",
845
+ block_id="block_id",
911
846
  )
912
847
 
913
848
 
914
849
  asyncio.run(main())
915
850
  """
916
851
  _response = await self._client_wrapper.httpx_client.request(
917
- f"v1/agents/{jsonable_encoder(agent_id)}/core_memory/blocks",
918
- method="POST",
919
- json={
920
- "value": value,
921
- "limit": limit,
922
- "name": name,
923
- "is_template": is_template,
924
- "label": label,
925
- "description": description,
926
- "metadata_": metadata,
927
- },
852
+ f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/detach/{jsonable_encoder(block_id)}",
853
+ method="PATCH",
928
854
  request_options=request_options,
929
- omit=OMIT,
930
855
  )
931
856
  try:
932
857
  if 200 <= _response.status_code < 300:
933
858
  return typing.cast(
934
- Memory,
859
+ AgentState,
935
860
  construct_type(
936
- type_=Memory, # type: ignore
861
+ type_=AgentState, # type: ignore
937
862
  object_=_response.json(),
938
863
  ),
939
864
  )