letta-client 0.1.41__py3-none-any.whl → 0.1.43__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.
- letta_client/__init__.py +10 -8
- letta_client/agents/__init__.py +5 -6
- letta_client/agents/blocks/client.py +753 -0
- letta_client/agents/client.py +32 -28
- letta_client/agents/core_memory/client.py +1 -734
- letta_client/agents/passages/__init__.py +2 -0
- letta_client/agents/{archival_memory → passages}/client.py +8 -8
- letta_client/agents/types/__init__.py +2 -4
- letta_client/agents/types/agents_search_response_agents_item.py +2 -2
- letta_client/agents/types/agents_search_response_agents_item_identity_ids.py +5 -0
- letta_client/core/client_wrapper.py +1 -1
- letta_client/identities/client.py +108 -50
- letta_client/templates/__init__.py +2 -4
- letta_client/templates/types/__init__.py +3 -7
- letta_client/templates/types/templates_create_agents_response_agents_item.py +3 -3
- letta_client/templates/types/templates_create_agents_response_agents_item_identity_ids.py +5 -0
- letta_client/types/__init__.py +6 -0
- letta_client/types/agent_state.py +2 -2
- letta_client/types/identity.py +8 -3
- letta_client/types/identity_create.py +6 -0
- letta_client/types/identity_property.py +38 -0
- letta_client/types/identity_property_type.py +5 -0
- letta_client/types/identity_property_value.py +5 -0
- {letta_client-0.1.41.dist-info → letta_client-0.1.43.dist-info}/METADATA +1 -1
- {letta_client-0.1.41.dist-info → letta_client-0.1.43.dist-info}/RECORD +27 -24
- letta_client/agents/types/agents_search_response_agents_item_identifier_key.py +0 -11
- letta_client/agents/types/agents_search_response_agents_item_identifier_key_item.py +0 -5
- letta_client/templates/types/templates_create_agents_response_agents_item_identifier_key.py +0 -13
- letta_client/templates/types/templates_create_agents_response_agents_item_identifier_key_item.py +0 -5
- /letta_client/agents/{archival_memory → blocks}/__init__.py +0 -0
- {letta_client-0.1.41.dist-info → letta_client-0.1.43.dist-info}/WHEEL +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
|
-
import typing
|
|
4
3
|
from ...core.client_wrapper import SyncClientWrapper
|
|
4
|
+
import typing
|
|
5
5
|
from ...core.request_options import RequestOptions
|
|
6
6
|
from ...types.memory import Memory
|
|
7
7
|
from ...core.jsonable_encoder import jsonable_encoder
|
|
@@ -10,13 +10,8 @@ from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
|
10
10
|
from ...types.http_validation_error import HttpValidationError
|
|
11
11
|
from json.decoder import JSONDecodeError
|
|
12
12
|
from ...core.api_error import ApiError
|
|
13
|
-
from ...types.block import Block
|
|
14
|
-
from ...types.agent_state import AgentState
|
|
15
13
|
from ...core.client_wrapper import AsyncClientWrapper
|
|
16
14
|
|
|
17
|
-
# this is used as the default value for optional parameters
|
|
18
|
-
OMIT = typing.cast(typing.Any, ...)
|
|
19
|
-
|
|
20
15
|
|
|
21
16
|
class CoreMemoryClient:
|
|
22
17
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
@@ -79,350 +74,6 @@ class CoreMemoryClient:
|
|
|
79
74
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
80
75
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
81
76
|
|
|
82
|
-
def retrieve_block(
|
|
83
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
84
|
-
) -> Block:
|
|
85
|
-
"""
|
|
86
|
-
Retrieve a memory block from an agent.
|
|
87
|
-
|
|
88
|
-
Parameters
|
|
89
|
-
----------
|
|
90
|
-
agent_id : str
|
|
91
|
-
|
|
92
|
-
block_label : str
|
|
93
|
-
|
|
94
|
-
request_options : typing.Optional[RequestOptions]
|
|
95
|
-
Request-specific configuration.
|
|
96
|
-
|
|
97
|
-
Returns
|
|
98
|
-
-------
|
|
99
|
-
Block
|
|
100
|
-
Successful Response
|
|
101
|
-
|
|
102
|
-
Examples
|
|
103
|
-
--------
|
|
104
|
-
from letta_client import Letta
|
|
105
|
-
|
|
106
|
-
client = Letta(
|
|
107
|
-
token="YOUR_TOKEN",
|
|
108
|
-
)
|
|
109
|
-
client.agents.core_memory.retrieve_block(
|
|
110
|
-
agent_id="agent_id",
|
|
111
|
-
block_label="block_label",
|
|
112
|
-
)
|
|
113
|
-
"""
|
|
114
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
115
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
|
|
116
|
-
method="GET",
|
|
117
|
-
request_options=request_options,
|
|
118
|
-
)
|
|
119
|
-
try:
|
|
120
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
138
|
-
_response_json = _response.json()
|
|
139
|
-
except JSONDecodeError:
|
|
140
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
141
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
142
|
-
|
|
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:
|
|
157
|
-
"""
|
|
158
|
-
Updates a memory block of an agent.
|
|
159
|
-
|
|
160
|
-
Parameters
|
|
161
|
-
----------
|
|
162
|
-
agent_id : str
|
|
163
|
-
|
|
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.
|
|
186
|
-
|
|
187
|
-
request_options : typing.Optional[RequestOptions]
|
|
188
|
-
Request-specific configuration.
|
|
189
|
-
|
|
190
|
-
Returns
|
|
191
|
-
-------
|
|
192
|
-
Block
|
|
193
|
-
Successful Response
|
|
194
|
-
|
|
195
|
-
Examples
|
|
196
|
-
--------
|
|
197
|
-
from letta_client import Letta
|
|
198
|
-
|
|
199
|
-
client = Letta(
|
|
200
|
-
token="YOUR_TOKEN",
|
|
201
|
-
)
|
|
202
|
-
client.agents.core_memory.modify_block(
|
|
203
|
-
agent_id="agent_id",
|
|
204
|
-
block_label="block_label",
|
|
205
|
-
)
|
|
206
|
-
"""
|
|
207
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
208
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
|
|
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
|
-
},
|
|
219
|
-
request_options=request_options,
|
|
220
|
-
omit=OMIT,
|
|
221
|
-
)
|
|
222
|
-
try:
|
|
223
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
241
|
-
_response_json = _response.json()
|
|
242
|
-
except JSONDecodeError:
|
|
243
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
244
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
245
|
-
|
|
246
|
-
def list_blocks(
|
|
247
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
248
|
-
) -> typing.List[Block]:
|
|
249
|
-
"""
|
|
250
|
-
Retrieve the memory blocks of a specific agent.
|
|
251
|
-
|
|
252
|
-
Parameters
|
|
253
|
-
----------
|
|
254
|
-
agent_id : str
|
|
255
|
-
|
|
256
|
-
request_options : typing.Optional[RequestOptions]
|
|
257
|
-
Request-specific configuration.
|
|
258
|
-
|
|
259
|
-
Returns
|
|
260
|
-
-------
|
|
261
|
-
typing.List[Block]
|
|
262
|
-
Successful Response
|
|
263
|
-
|
|
264
|
-
Examples
|
|
265
|
-
--------
|
|
266
|
-
from letta_client import Letta
|
|
267
|
-
|
|
268
|
-
client = Letta(
|
|
269
|
-
token="YOUR_TOKEN",
|
|
270
|
-
)
|
|
271
|
-
client.agents.core_memory.list_blocks(
|
|
272
|
-
agent_id="agent_id",
|
|
273
|
-
)
|
|
274
|
-
"""
|
|
275
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
276
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks",
|
|
277
|
-
method="GET",
|
|
278
|
-
request_options=request_options,
|
|
279
|
-
)
|
|
280
|
-
try:
|
|
281
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
299
|
-
_response_json = _response.json()
|
|
300
|
-
except JSONDecodeError:
|
|
301
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
302
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
303
|
-
|
|
304
|
-
def attach_block(
|
|
305
|
-
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
306
|
-
) -> AgentState:
|
|
307
|
-
"""
|
|
308
|
-
Attach a block to an agent.
|
|
309
|
-
|
|
310
|
-
Parameters
|
|
311
|
-
----------
|
|
312
|
-
agent_id : str
|
|
313
|
-
|
|
314
|
-
block_id : str
|
|
315
|
-
|
|
316
|
-
request_options : typing.Optional[RequestOptions]
|
|
317
|
-
Request-specific configuration.
|
|
318
|
-
|
|
319
|
-
Returns
|
|
320
|
-
-------
|
|
321
|
-
AgentState
|
|
322
|
-
Successful Response
|
|
323
|
-
|
|
324
|
-
Examples
|
|
325
|
-
--------
|
|
326
|
-
from letta_client import Letta
|
|
327
|
-
|
|
328
|
-
client = Letta(
|
|
329
|
-
token="YOUR_TOKEN",
|
|
330
|
-
)
|
|
331
|
-
client.agents.core_memory.attach_block(
|
|
332
|
-
agent_id="agent_id",
|
|
333
|
-
block_id="block_id",
|
|
334
|
-
)
|
|
335
|
-
"""
|
|
336
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
337
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/attach/{jsonable_encoder(block_id)}",
|
|
338
|
-
method="PATCH",
|
|
339
|
-
request_options=request_options,
|
|
340
|
-
)
|
|
341
|
-
try:
|
|
342
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
360
|
-
_response_json = _response.json()
|
|
361
|
-
except JSONDecodeError:
|
|
362
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
363
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
364
|
-
|
|
365
|
-
def detach_block(
|
|
366
|
-
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
367
|
-
) -> AgentState:
|
|
368
|
-
"""
|
|
369
|
-
Detach a block from an agent.
|
|
370
|
-
|
|
371
|
-
Parameters
|
|
372
|
-
----------
|
|
373
|
-
agent_id : str
|
|
374
|
-
|
|
375
|
-
block_id : str
|
|
376
|
-
|
|
377
|
-
request_options : typing.Optional[RequestOptions]
|
|
378
|
-
Request-specific configuration.
|
|
379
|
-
|
|
380
|
-
Returns
|
|
381
|
-
-------
|
|
382
|
-
AgentState
|
|
383
|
-
Successful Response
|
|
384
|
-
|
|
385
|
-
Examples
|
|
386
|
-
--------
|
|
387
|
-
from letta_client import Letta
|
|
388
|
-
|
|
389
|
-
client = Letta(
|
|
390
|
-
token="YOUR_TOKEN",
|
|
391
|
-
)
|
|
392
|
-
client.agents.core_memory.detach_block(
|
|
393
|
-
agent_id="agent_id",
|
|
394
|
-
block_id="block_id",
|
|
395
|
-
)
|
|
396
|
-
"""
|
|
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",
|
|
400
|
-
request_options=request_options,
|
|
401
|
-
)
|
|
402
|
-
try:
|
|
403
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
421
|
-
_response_json = _response.json()
|
|
422
|
-
except JSONDecodeError:
|
|
423
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
424
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
425
|
-
|
|
426
77
|
|
|
427
78
|
class AsyncCoreMemoryClient:
|
|
428
79
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
@@ -492,387 +143,3 @@ class AsyncCoreMemoryClient:
|
|
|
492
143
|
except JSONDecodeError:
|
|
493
144
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
494
145
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
495
|
-
|
|
496
|
-
async def retrieve_block(
|
|
497
|
-
self, agent_id: str, block_label: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
498
|
-
) -> Block:
|
|
499
|
-
"""
|
|
500
|
-
Retrieve a memory block from an agent.
|
|
501
|
-
|
|
502
|
-
Parameters
|
|
503
|
-
----------
|
|
504
|
-
agent_id : str
|
|
505
|
-
|
|
506
|
-
block_label : str
|
|
507
|
-
|
|
508
|
-
request_options : typing.Optional[RequestOptions]
|
|
509
|
-
Request-specific configuration.
|
|
510
|
-
|
|
511
|
-
Returns
|
|
512
|
-
-------
|
|
513
|
-
Block
|
|
514
|
-
Successful Response
|
|
515
|
-
|
|
516
|
-
Examples
|
|
517
|
-
--------
|
|
518
|
-
import asyncio
|
|
519
|
-
|
|
520
|
-
from letta_client import AsyncLetta
|
|
521
|
-
|
|
522
|
-
client = AsyncLetta(
|
|
523
|
-
token="YOUR_TOKEN",
|
|
524
|
-
)
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
async def main() -> None:
|
|
528
|
-
await client.agents.core_memory.retrieve_block(
|
|
529
|
-
agent_id="agent_id",
|
|
530
|
-
block_label="block_label",
|
|
531
|
-
)
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
asyncio.run(main())
|
|
535
|
-
"""
|
|
536
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
537
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
|
|
538
|
-
method="GET",
|
|
539
|
-
request_options=request_options,
|
|
540
|
-
)
|
|
541
|
-
try:
|
|
542
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
560
|
-
_response_json = _response.json()
|
|
561
|
-
except JSONDecodeError:
|
|
562
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
563
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
564
|
-
|
|
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:
|
|
579
|
-
"""
|
|
580
|
-
Updates a memory block of an agent.
|
|
581
|
-
|
|
582
|
-
Parameters
|
|
583
|
-
----------
|
|
584
|
-
agent_id : str
|
|
585
|
-
|
|
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.
|
|
608
|
-
|
|
609
|
-
request_options : typing.Optional[RequestOptions]
|
|
610
|
-
Request-specific configuration.
|
|
611
|
-
|
|
612
|
-
Returns
|
|
613
|
-
-------
|
|
614
|
-
Block
|
|
615
|
-
Successful Response
|
|
616
|
-
|
|
617
|
-
Examples
|
|
618
|
-
--------
|
|
619
|
-
import asyncio
|
|
620
|
-
|
|
621
|
-
from letta_client import AsyncLetta
|
|
622
|
-
|
|
623
|
-
client = AsyncLetta(
|
|
624
|
-
token="YOUR_TOKEN",
|
|
625
|
-
)
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
async def main() -> None:
|
|
629
|
-
await client.agents.core_memory.modify_block(
|
|
630
|
-
agent_id="agent_id",
|
|
631
|
-
block_label="block_label",
|
|
632
|
-
)
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
asyncio.run(main())
|
|
636
|
-
"""
|
|
637
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
638
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/{jsonable_encoder(block_label)}",
|
|
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
|
-
},
|
|
649
|
-
request_options=request_options,
|
|
650
|
-
omit=OMIT,
|
|
651
|
-
)
|
|
652
|
-
try:
|
|
653
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
671
|
-
_response_json = _response.json()
|
|
672
|
-
except JSONDecodeError:
|
|
673
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
674
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
675
|
-
|
|
676
|
-
async def list_blocks(
|
|
677
|
-
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
678
|
-
) -> typing.List[Block]:
|
|
679
|
-
"""
|
|
680
|
-
Retrieve the memory blocks of a specific agent.
|
|
681
|
-
|
|
682
|
-
Parameters
|
|
683
|
-
----------
|
|
684
|
-
agent_id : str
|
|
685
|
-
|
|
686
|
-
request_options : typing.Optional[RequestOptions]
|
|
687
|
-
Request-specific configuration.
|
|
688
|
-
|
|
689
|
-
Returns
|
|
690
|
-
-------
|
|
691
|
-
typing.List[Block]
|
|
692
|
-
Successful Response
|
|
693
|
-
|
|
694
|
-
Examples
|
|
695
|
-
--------
|
|
696
|
-
import asyncio
|
|
697
|
-
|
|
698
|
-
from letta_client import AsyncLetta
|
|
699
|
-
|
|
700
|
-
client = AsyncLetta(
|
|
701
|
-
token="YOUR_TOKEN",
|
|
702
|
-
)
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
async def main() -> None:
|
|
706
|
-
await client.agents.core_memory.list_blocks(
|
|
707
|
-
agent_id="agent_id",
|
|
708
|
-
)
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
asyncio.run(main())
|
|
712
|
-
"""
|
|
713
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
714
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks",
|
|
715
|
-
method="GET",
|
|
716
|
-
request_options=request_options,
|
|
717
|
-
)
|
|
718
|
-
try:
|
|
719
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
737
|
-
_response_json = _response.json()
|
|
738
|
-
except JSONDecodeError:
|
|
739
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
740
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
741
|
-
|
|
742
|
-
async def attach_block(
|
|
743
|
-
self, agent_id: str, block_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
744
|
-
) -> AgentState:
|
|
745
|
-
"""
|
|
746
|
-
Attach a block to an agent.
|
|
747
|
-
|
|
748
|
-
Parameters
|
|
749
|
-
----------
|
|
750
|
-
agent_id : str
|
|
751
|
-
|
|
752
|
-
block_id : str
|
|
753
|
-
|
|
754
|
-
request_options : typing.Optional[RequestOptions]
|
|
755
|
-
Request-specific configuration.
|
|
756
|
-
|
|
757
|
-
Returns
|
|
758
|
-
-------
|
|
759
|
-
AgentState
|
|
760
|
-
Successful Response
|
|
761
|
-
|
|
762
|
-
Examples
|
|
763
|
-
--------
|
|
764
|
-
import asyncio
|
|
765
|
-
|
|
766
|
-
from letta_client import AsyncLetta
|
|
767
|
-
|
|
768
|
-
client = AsyncLetta(
|
|
769
|
-
token="YOUR_TOKEN",
|
|
770
|
-
)
|
|
771
|
-
|
|
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
|
|
822
|
-
|
|
823
|
-
request_options : typing.Optional[RequestOptions]
|
|
824
|
-
Request-specific configuration.
|
|
825
|
-
|
|
826
|
-
Returns
|
|
827
|
-
-------
|
|
828
|
-
AgentState
|
|
829
|
-
Successful Response
|
|
830
|
-
|
|
831
|
-
Examples
|
|
832
|
-
--------
|
|
833
|
-
import asyncio
|
|
834
|
-
|
|
835
|
-
from letta_client import AsyncLetta
|
|
836
|
-
|
|
837
|
-
client = AsyncLetta(
|
|
838
|
-
token="YOUR_TOKEN",
|
|
839
|
-
)
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
async def main() -> None:
|
|
843
|
-
await client.agents.core_memory.detach_block(
|
|
844
|
-
agent_id="agent_id",
|
|
845
|
-
block_id="block_id",
|
|
846
|
-
)
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
asyncio.run(main())
|
|
850
|
-
"""
|
|
851
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
852
|
-
f"v1/agents/{jsonable_encoder(agent_id)}/core-memory/blocks/detach/{jsonable_encoder(block_id)}",
|
|
853
|
-
method="PATCH",
|
|
854
|
-
request_options=request_options,
|
|
855
|
-
)
|
|
856
|
-
try:
|
|
857
|
-
if 200 <= _response.status_code < 300:
|
|
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
|
-
)
|
|
875
|
-
_response_json = _response.json()
|
|
876
|
-
except JSONDecodeError:
|
|
877
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
878
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|