letta-client 0.1.217__py3-none-any.whl → 0.1.219__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/agents/__init__.py +16 -1
- letta_client/agents/client.py +8 -410
- letta_client/agents/files/__init__.py +2 -0
- letta_client/agents/files/client.py +430 -0
- letta_client/agents/folders/__init__.py +2 -0
- letta_client/agents/folders/client.py +412 -0
- letta_client/core/client_wrapper.py +1 -1
- letta_client/folders/__init__.py +3 -0
- letta_client/folders/client.py +36 -650
- letta_client/folders/files/__init__.py +2 -0
- letta_client/folders/files/client.py +474 -0
- letta_client/folders/passages/__init__.py +2 -0
- letta_client/folders/passages/client.py +189 -0
- {letta_client-0.1.217.dist-info → letta_client-0.1.219.dist-info}/METADATA +1 -1
- {letta_client-0.1.217.dist-info → letta_client-0.1.219.dist-info}/RECORD +16 -8
- {letta_client-0.1.217.dist-info → letta_client-0.1.219.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
from ...core.client_wrapper import SyncClientWrapper
|
|
4
|
+
import typing
|
|
5
|
+
from ...core.request_options import RequestOptions
|
|
6
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
7
|
+
from ...core.unchecked_base_model import construct_type
|
|
8
|
+
from ...errors.unprocessable_entity_error import UnprocessableEntityError
|
|
9
|
+
from ...types.http_validation_error import HttpValidationError
|
|
10
|
+
from json.decoder import JSONDecodeError
|
|
11
|
+
from ...core.api_error import ApiError
|
|
12
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FilesClient:
|
|
16
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
17
|
+
self._client_wrapper = client_wrapper
|
|
18
|
+
|
|
19
|
+
def close_all(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[str]:
|
|
20
|
+
"""
|
|
21
|
+
Closes all currently open files for a given agent.
|
|
22
|
+
|
|
23
|
+
This endpoint updates the file state for the agent so that no files are marked as open.
|
|
24
|
+
Typically used to reset the working memory view for the agent.
|
|
25
|
+
|
|
26
|
+
Parameters
|
|
27
|
+
----------
|
|
28
|
+
agent_id : str
|
|
29
|
+
|
|
30
|
+
request_options : typing.Optional[RequestOptions]
|
|
31
|
+
Request-specific configuration.
|
|
32
|
+
|
|
33
|
+
Returns
|
|
34
|
+
-------
|
|
35
|
+
typing.List[str]
|
|
36
|
+
Successful Response
|
|
37
|
+
|
|
38
|
+
Examples
|
|
39
|
+
--------
|
|
40
|
+
from letta_client import Letta
|
|
41
|
+
|
|
42
|
+
client = Letta(
|
|
43
|
+
project="YOUR_PROJECT",
|
|
44
|
+
token="YOUR_TOKEN",
|
|
45
|
+
)
|
|
46
|
+
client.agents.files.close_all(
|
|
47
|
+
agent_id="agent_id",
|
|
48
|
+
)
|
|
49
|
+
"""
|
|
50
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
51
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/files/close-all",
|
|
52
|
+
method="PATCH",
|
|
53
|
+
request_options=request_options,
|
|
54
|
+
)
|
|
55
|
+
try:
|
|
56
|
+
if 200 <= _response.status_code < 300:
|
|
57
|
+
return typing.cast(
|
|
58
|
+
typing.List[str],
|
|
59
|
+
construct_type(
|
|
60
|
+
type_=typing.List[str], # type: ignore
|
|
61
|
+
object_=_response.json(),
|
|
62
|
+
),
|
|
63
|
+
)
|
|
64
|
+
if _response.status_code == 422:
|
|
65
|
+
raise UnprocessableEntityError(
|
|
66
|
+
typing.cast(
|
|
67
|
+
HttpValidationError,
|
|
68
|
+
construct_type(
|
|
69
|
+
type_=HttpValidationError, # type: ignore
|
|
70
|
+
object_=_response.json(),
|
|
71
|
+
),
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
_response_json = _response.json()
|
|
75
|
+
except JSONDecodeError:
|
|
76
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
77
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
78
|
+
|
|
79
|
+
def open(
|
|
80
|
+
self, agent_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
81
|
+
) -> typing.List[str]:
|
|
82
|
+
"""
|
|
83
|
+
Opens a specific file for a given agent.
|
|
84
|
+
|
|
85
|
+
This endpoint marks a specific file as open in the agent's file state.
|
|
86
|
+
The file will be included in the agent's working memory view.
|
|
87
|
+
Returns a list of file names that were closed due to LRU eviction.
|
|
88
|
+
|
|
89
|
+
Parameters
|
|
90
|
+
----------
|
|
91
|
+
agent_id : str
|
|
92
|
+
|
|
93
|
+
file_id : str
|
|
94
|
+
|
|
95
|
+
request_options : typing.Optional[RequestOptions]
|
|
96
|
+
Request-specific configuration.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
typing.List[str]
|
|
101
|
+
Successful Response
|
|
102
|
+
|
|
103
|
+
Examples
|
|
104
|
+
--------
|
|
105
|
+
from letta_client import Letta
|
|
106
|
+
|
|
107
|
+
client = Letta(
|
|
108
|
+
project="YOUR_PROJECT",
|
|
109
|
+
token="YOUR_TOKEN",
|
|
110
|
+
)
|
|
111
|
+
client.agents.files.open(
|
|
112
|
+
agent_id="agent_id",
|
|
113
|
+
file_id="file_id",
|
|
114
|
+
)
|
|
115
|
+
"""
|
|
116
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
117
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/files/{jsonable_encoder(file_id)}/open",
|
|
118
|
+
method="PATCH",
|
|
119
|
+
request_options=request_options,
|
|
120
|
+
)
|
|
121
|
+
try:
|
|
122
|
+
if 200 <= _response.status_code < 300:
|
|
123
|
+
return typing.cast(
|
|
124
|
+
typing.List[str],
|
|
125
|
+
construct_type(
|
|
126
|
+
type_=typing.List[str], # type: ignore
|
|
127
|
+
object_=_response.json(),
|
|
128
|
+
),
|
|
129
|
+
)
|
|
130
|
+
if _response.status_code == 422:
|
|
131
|
+
raise UnprocessableEntityError(
|
|
132
|
+
typing.cast(
|
|
133
|
+
HttpValidationError,
|
|
134
|
+
construct_type(
|
|
135
|
+
type_=HttpValidationError, # type: ignore
|
|
136
|
+
object_=_response.json(),
|
|
137
|
+
),
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
_response_json = _response.json()
|
|
141
|
+
except JSONDecodeError:
|
|
142
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
143
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
144
|
+
|
|
145
|
+
def close(
|
|
146
|
+
self, agent_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
147
|
+
) -> typing.Optional[typing.Any]:
|
|
148
|
+
"""
|
|
149
|
+
Closes a specific file for a given agent.
|
|
150
|
+
|
|
151
|
+
This endpoint marks a specific file as closed in the agent's file state.
|
|
152
|
+
The file will be removed from the agent's working memory view.
|
|
153
|
+
|
|
154
|
+
Parameters
|
|
155
|
+
----------
|
|
156
|
+
agent_id : str
|
|
157
|
+
|
|
158
|
+
file_id : str
|
|
159
|
+
|
|
160
|
+
request_options : typing.Optional[RequestOptions]
|
|
161
|
+
Request-specific configuration.
|
|
162
|
+
|
|
163
|
+
Returns
|
|
164
|
+
-------
|
|
165
|
+
typing.Optional[typing.Any]
|
|
166
|
+
Successful Response
|
|
167
|
+
|
|
168
|
+
Examples
|
|
169
|
+
--------
|
|
170
|
+
from letta_client import Letta
|
|
171
|
+
|
|
172
|
+
client = Letta(
|
|
173
|
+
project="YOUR_PROJECT",
|
|
174
|
+
token="YOUR_TOKEN",
|
|
175
|
+
)
|
|
176
|
+
client.agents.files.close(
|
|
177
|
+
agent_id="agent_id",
|
|
178
|
+
file_id="file_id",
|
|
179
|
+
)
|
|
180
|
+
"""
|
|
181
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
182
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/files/{jsonable_encoder(file_id)}/close",
|
|
183
|
+
method="PATCH",
|
|
184
|
+
request_options=request_options,
|
|
185
|
+
)
|
|
186
|
+
try:
|
|
187
|
+
if 200 <= _response.status_code < 300:
|
|
188
|
+
return typing.cast(
|
|
189
|
+
typing.Optional[typing.Any],
|
|
190
|
+
construct_type(
|
|
191
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
192
|
+
object_=_response.json(),
|
|
193
|
+
),
|
|
194
|
+
)
|
|
195
|
+
if _response.status_code == 422:
|
|
196
|
+
raise UnprocessableEntityError(
|
|
197
|
+
typing.cast(
|
|
198
|
+
HttpValidationError,
|
|
199
|
+
construct_type(
|
|
200
|
+
type_=HttpValidationError, # type: ignore
|
|
201
|
+
object_=_response.json(),
|
|
202
|
+
),
|
|
203
|
+
)
|
|
204
|
+
)
|
|
205
|
+
_response_json = _response.json()
|
|
206
|
+
except JSONDecodeError:
|
|
207
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
208
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class AsyncFilesClient:
|
|
212
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
213
|
+
self._client_wrapper = client_wrapper
|
|
214
|
+
|
|
215
|
+
async def close_all(
|
|
216
|
+
self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
217
|
+
) -> typing.List[str]:
|
|
218
|
+
"""
|
|
219
|
+
Closes all currently open files for a given agent.
|
|
220
|
+
|
|
221
|
+
This endpoint updates the file state for the agent so that no files are marked as open.
|
|
222
|
+
Typically used to reset the working memory view for the agent.
|
|
223
|
+
|
|
224
|
+
Parameters
|
|
225
|
+
----------
|
|
226
|
+
agent_id : str
|
|
227
|
+
|
|
228
|
+
request_options : typing.Optional[RequestOptions]
|
|
229
|
+
Request-specific configuration.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
typing.List[str]
|
|
234
|
+
Successful Response
|
|
235
|
+
|
|
236
|
+
Examples
|
|
237
|
+
--------
|
|
238
|
+
import asyncio
|
|
239
|
+
|
|
240
|
+
from letta_client import AsyncLetta
|
|
241
|
+
|
|
242
|
+
client = AsyncLetta(
|
|
243
|
+
project="YOUR_PROJECT",
|
|
244
|
+
token="YOUR_TOKEN",
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
async def main() -> None:
|
|
249
|
+
await client.agents.files.close_all(
|
|
250
|
+
agent_id="agent_id",
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
asyncio.run(main())
|
|
255
|
+
"""
|
|
256
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
257
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/files/close-all",
|
|
258
|
+
method="PATCH",
|
|
259
|
+
request_options=request_options,
|
|
260
|
+
)
|
|
261
|
+
try:
|
|
262
|
+
if 200 <= _response.status_code < 300:
|
|
263
|
+
return typing.cast(
|
|
264
|
+
typing.List[str],
|
|
265
|
+
construct_type(
|
|
266
|
+
type_=typing.List[str], # type: ignore
|
|
267
|
+
object_=_response.json(),
|
|
268
|
+
),
|
|
269
|
+
)
|
|
270
|
+
if _response.status_code == 422:
|
|
271
|
+
raise UnprocessableEntityError(
|
|
272
|
+
typing.cast(
|
|
273
|
+
HttpValidationError,
|
|
274
|
+
construct_type(
|
|
275
|
+
type_=HttpValidationError, # type: ignore
|
|
276
|
+
object_=_response.json(),
|
|
277
|
+
),
|
|
278
|
+
)
|
|
279
|
+
)
|
|
280
|
+
_response_json = _response.json()
|
|
281
|
+
except JSONDecodeError:
|
|
282
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
283
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
284
|
+
|
|
285
|
+
async def open(
|
|
286
|
+
self, agent_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
287
|
+
) -> typing.List[str]:
|
|
288
|
+
"""
|
|
289
|
+
Opens a specific file for a given agent.
|
|
290
|
+
|
|
291
|
+
This endpoint marks a specific file as open in the agent's file state.
|
|
292
|
+
The file will be included in the agent's working memory view.
|
|
293
|
+
Returns a list of file names that were closed due to LRU eviction.
|
|
294
|
+
|
|
295
|
+
Parameters
|
|
296
|
+
----------
|
|
297
|
+
agent_id : str
|
|
298
|
+
|
|
299
|
+
file_id : str
|
|
300
|
+
|
|
301
|
+
request_options : typing.Optional[RequestOptions]
|
|
302
|
+
Request-specific configuration.
|
|
303
|
+
|
|
304
|
+
Returns
|
|
305
|
+
-------
|
|
306
|
+
typing.List[str]
|
|
307
|
+
Successful Response
|
|
308
|
+
|
|
309
|
+
Examples
|
|
310
|
+
--------
|
|
311
|
+
import asyncio
|
|
312
|
+
|
|
313
|
+
from letta_client import AsyncLetta
|
|
314
|
+
|
|
315
|
+
client = AsyncLetta(
|
|
316
|
+
project="YOUR_PROJECT",
|
|
317
|
+
token="YOUR_TOKEN",
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
async def main() -> None:
|
|
322
|
+
await client.agents.files.open(
|
|
323
|
+
agent_id="agent_id",
|
|
324
|
+
file_id="file_id",
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
asyncio.run(main())
|
|
329
|
+
"""
|
|
330
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
331
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/files/{jsonable_encoder(file_id)}/open",
|
|
332
|
+
method="PATCH",
|
|
333
|
+
request_options=request_options,
|
|
334
|
+
)
|
|
335
|
+
try:
|
|
336
|
+
if 200 <= _response.status_code < 300:
|
|
337
|
+
return typing.cast(
|
|
338
|
+
typing.List[str],
|
|
339
|
+
construct_type(
|
|
340
|
+
type_=typing.List[str], # type: ignore
|
|
341
|
+
object_=_response.json(),
|
|
342
|
+
),
|
|
343
|
+
)
|
|
344
|
+
if _response.status_code == 422:
|
|
345
|
+
raise UnprocessableEntityError(
|
|
346
|
+
typing.cast(
|
|
347
|
+
HttpValidationError,
|
|
348
|
+
construct_type(
|
|
349
|
+
type_=HttpValidationError, # type: ignore
|
|
350
|
+
object_=_response.json(),
|
|
351
|
+
),
|
|
352
|
+
)
|
|
353
|
+
)
|
|
354
|
+
_response_json = _response.json()
|
|
355
|
+
except JSONDecodeError:
|
|
356
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
357
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
358
|
+
|
|
359
|
+
async def close(
|
|
360
|
+
self, agent_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
361
|
+
) -> typing.Optional[typing.Any]:
|
|
362
|
+
"""
|
|
363
|
+
Closes a specific file for a given agent.
|
|
364
|
+
|
|
365
|
+
This endpoint marks a specific file as closed in the agent's file state.
|
|
366
|
+
The file will be removed from the agent's working memory view.
|
|
367
|
+
|
|
368
|
+
Parameters
|
|
369
|
+
----------
|
|
370
|
+
agent_id : str
|
|
371
|
+
|
|
372
|
+
file_id : str
|
|
373
|
+
|
|
374
|
+
request_options : typing.Optional[RequestOptions]
|
|
375
|
+
Request-specific configuration.
|
|
376
|
+
|
|
377
|
+
Returns
|
|
378
|
+
-------
|
|
379
|
+
typing.Optional[typing.Any]
|
|
380
|
+
Successful Response
|
|
381
|
+
|
|
382
|
+
Examples
|
|
383
|
+
--------
|
|
384
|
+
import asyncio
|
|
385
|
+
|
|
386
|
+
from letta_client import AsyncLetta
|
|
387
|
+
|
|
388
|
+
client = AsyncLetta(
|
|
389
|
+
project="YOUR_PROJECT",
|
|
390
|
+
token="YOUR_TOKEN",
|
|
391
|
+
)
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
async def main() -> None:
|
|
395
|
+
await client.agents.files.close(
|
|
396
|
+
agent_id="agent_id",
|
|
397
|
+
file_id="file_id",
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
asyncio.run(main())
|
|
402
|
+
"""
|
|
403
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
404
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/files/{jsonable_encoder(file_id)}/close",
|
|
405
|
+
method="PATCH",
|
|
406
|
+
request_options=request_options,
|
|
407
|
+
)
|
|
408
|
+
try:
|
|
409
|
+
if 200 <= _response.status_code < 300:
|
|
410
|
+
return typing.cast(
|
|
411
|
+
typing.Optional[typing.Any],
|
|
412
|
+
construct_type(
|
|
413
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
414
|
+
object_=_response.json(),
|
|
415
|
+
),
|
|
416
|
+
)
|
|
417
|
+
if _response.status_code == 422:
|
|
418
|
+
raise UnprocessableEntityError(
|
|
419
|
+
typing.cast(
|
|
420
|
+
HttpValidationError,
|
|
421
|
+
construct_type(
|
|
422
|
+
type_=HttpValidationError, # type: ignore
|
|
423
|
+
object_=_response.json(),
|
|
424
|
+
),
|
|
425
|
+
)
|
|
426
|
+
)
|
|
427
|
+
_response_json = _response.json()
|
|
428
|
+
except JSONDecodeError:
|
|
429
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
430
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|