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.

@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,474 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ...core.client_wrapper import SyncClientWrapper
5
+ from ... import core
6
+ from ...types.duplicate_file_handling import DuplicateFileHandling
7
+ from ...core.request_options import RequestOptions
8
+ from ...types.file_metadata import FileMetadata
9
+ from ...core.jsonable_encoder import jsonable_encoder
10
+ from ...core.unchecked_base_model import construct_type
11
+ from ...errors.unprocessable_entity_error import UnprocessableEntityError
12
+ from ...types.http_validation_error import HttpValidationError
13
+ from json.decoder import JSONDecodeError
14
+ from ...core.api_error import ApiError
15
+ from ...core.client_wrapper import AsyncClientWrapper
16
+
17
+ # this is used as the default value for optional parameters
18
+ OMIT = typing.cast(typing.Any, ...)
19
+
20
+
21
+ class FilesClient:
22
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
23
+ self._client_wrapper = client_wrapper
24
+
25
+ def upload(
26
+ self,
27
+ folder_id: str,
28
+ *,
29
+ file: core.File,
30
+ duplicate_handling: typing.Optional[DuplicateFileHandling] = None,
31
+ request_options: typing.Optional[RequestOptions] = None,
32
+ ) -> FileMetadata:
33
+ """
34
+ Upload a file to a data folder.
35
+
36
+ Parameters
37
+ ----------
38
+ folder_id : str
39
+
40
+ file : core.File
41
+ See core.File for more documentation
42
+
43
+ duplicate_handling : typing.Optional[DuplicateFileHandling]
44
+ How to handle duplicate filenames
45
+
46
+ request_options : typing.Optional[RequestOptions]
47
+ Request-specific configuration.
48
+
49
+ Returns
50
+ -------
51
+ FileMetadata
52
+ Successful Response
53
+
54
+ Examples
55
+ --------
56
+ from letta_client import Letta
57
+
58
+ client = Letta(
59
+ project="YOUR_PROJECT",
60
+ token="YOUR_TOKEN",
61
+ )
62
+ client.folders.files.upload(
63
+ folder_id="folder_id",
64
+ )
65
+ """
66
+ _response = self._client_wrapper.httpx_client.request(
67
+ f"v1/folders/{jsonable_encoder(folder_id)}/upload",
68
+ method="POST",
69
+ params={
70
+ "duplicate_handling": duplicate_handling,
71
+ },
72
+ data={},
73
+ files={
74
+ "file": file,
75
+ },
76
+ request_options=request_options,
77
+ omit=OMIT,
78
+ )
79
+ try:
80
+ if 200 <= _response.status_code < 300:
81
+ return typing.cast(
82
+ FileMetadata,
83
+ construct_type(
84
+ type_=FileMetadata, # type: ignore
85
+ object_=_response.json(),
86
+ ),
87
+ )
88
+ if _response.status_code == 422:
89
+ raise UnprocessableEntityError(
90
+ typing.cast(
91
+ HttpValidationError,
92
+ construct_type(
93
+ type_=HttpValidationError, # type: ignore
94
+ object_=_response.json(),
95
+ ),
96
+ )
97
+ )
98
+ _response_json = _response.json()
99
+ except JSONDecodeError:
100
+ raise ApiError(status_code=_response.status_code, body=_response.text)
101
+ raise ApiError(status_code=_response.status_code, body=_response_json)
102
+
103
+ def list(
104
+ self,
105
+ folder_id: str,
106
+ *,
107
+ limit: typing.Optional[int] = None,
108
+ after: typing.Optional[str] = None,
109
+ include_content: typing.Optional[bool] = None,
110
+ request_options: typing.Optional[RequestOptions] = None,
111
+ ) -> typing.List[FileMetadata]:
112
+ """
113
+ List paginated files associated with a data folder.
114
+
115
+ Parameters
116
+ ----------
117
+ folder_id : str
118
+
119
+ limit : typing.Optional[int]
120
+ Number of files to return
121
+
122
+ after : typing.Optional[str]
123
+ Pagination cursor to fetch the next set of results
124
+
125
+ include_content : typing.Optional[bool]
126
+ Whether to include full file content
127
+
128
+ request_options : typing.Optional[RequestOptions]
129
+ Request-specific configuration.
130
+
131
+ Returns
132
+ -------
133
+ typing.List[FileMetadata]
134
+ Successful Response
135
+
136
+ Examples
137
+ --------
138
+ from letta_client import Letta
139
+
140
+ client = Letta(
141
+ project="YOUR_PROJECT",
142
+ token="YOUR_TOKEN",
143
+ )
144
+ client.folders.files.list(
145
+ folder_id="folder_id",
146
+ )
147
+ """
148
+ _response = self._client_wrapper.httpx_client.request(
149
+ f"v1/folders/{jsonable_encoder(folder_id)}/files",
150
+ method="GET",
151
+ params={
152
+ "limit": limit,
153
+ "after": after,
154
+ "include_content": include_content,
155
+ },
156
+ request_options=request_options,
157
+ )
158
+ try:
159
+ if 200 <= _response.status_code < 300:
160
+ return typing.cast(
161
+ typing.List[FileMetadata],
162
+ construct_type(
163
+ type_=typing.List[FileMetadata], # type: ignore
164
+ object_=_response.json(),
165
+ ),
166
+ )
167
+ if _response.status_code == 422:
168
+ raise UnprocessableEntityError(
169
+ typing.cast(
170
+ HttpValidationError,
171
+ construct_type(
172
+ type_=HttpValidationError, # type: ignore
173
+ object_=_response.json(),
174
+ ),
175
+ )
176
+ )
177
+ _response_json = _response.json()
178
+ except JSONDecodeError:
179
+ raise ApiError(status_code=_response.status_code, body=_response.text)
180
+ raise ApiError(status_code=_response.status_code, body=_response_json)
181
+
182
+ def delete(self, folder_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
183
+ """
184
+ Delete a file from a folder.
185
+
186
+ Parameters
187
+ ----------
188
+ folder_id : str
189
+
190
+ file_id : str
191
+
192
+ request_options : typing.Optional[RequestOptions]
193
+ Request-specific configuration.
194
+
195
+ Returns
196
+ -------
197
+ None
198
+
199
+ Examples
200
+ --------
201
+ from letta_client import Letta
202
+
203
+ client = Letta(
204
+ project="YOUR_PROJECT",
205
+ token="YOUR_TOKEN",
206
+ )
207
+ client.folders.files.delete(
208
+ folder_id="folder_id",
209
+ file_id="file_id",
210
+ )
211
+ """
212
+ _response = self._client_wrapper.httpx_client.request(
213
+ f"v1/folders/{jsonable_encoder(folder_id)}/{jsonable_encoder(file_id)}",
214
+ method="DELETE",
215
+ request_options=request_options,
216
+ )
217
+ try:
218
+ if 200 <= _response.status_code < 300:
219
+ return
220
+ if _response.status_code == 422:
221
+ raise UnprocessableEntityError(
222
+ typing.cast(
223
+ HttpValidationError,
224
+ construct_type(
225
+ type_=HttpValidationError, # type: ignore
226
+ object_=_response.json(),
227
+ ),
228
+ )
229
+ )
230
+ _response_json = _response.json()
231
+ except JSONDecodeError:
232
+ raise ApiError(status_code=_response.status_code, body=_response.text)
233
+ raise ApiError(status_code=_response.status_code, body=_response_json)
234
+
235
+
236
+ class AsyncFilesClient:
237
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
238
+ self._client_wrapper = client_wrapper
239
+
240
+ async def upload(
241
+ self,
242
+ folder_id: str,
243
+ *,
244
+ file: core.File,
245
+ duplicate_handling: typing.Optional[DuplicateFileHandling] = None,
246
+ request_options: typing.Optional[RequestOptions] = None,
247
+ ) -> FileMetadata:
248
+ """
249
+ Upload a file to a data folder.
250
+
251
+ Parameters
252
+ ----------
253
+ folder_id : str
254
+
255
+ file : core.File
256
+ See core.File for more documentation
257
+
258
+ duplicate_handling : typing.Optional[DuplicateFileHandling]
259
+ How to handle duplicate filenames
260
+
261
+ request_options : typing.Optional[RequestOptions]
262
+ Request-specific configuration.
263
+
264
+ Returns
265
+ -------
266
+ FileMetadata
267
+ Successful Response
268
+
269
+ Examples
270
+ --------
271
+ import asyncio
272
+
273
+ from letta_client import AsyncLetta
274
+
275
+ client = AsyncLetta(
276
+ project="YOUR_PROJECT",
277
+ token="YOUR_TOKEN",
278
+ )
279
+
280
+
281
+ async def main() -> None:
282
+ await client.folders.files.upload(
283
+ folder_id="folder_id",
284
+ )
285
+
286
+
287
+ asyncio.run(main())
288
+ """
289
+ _response = await self._client_wrapper.httpx_client.request(
290
+ f"v1/folders/{jsonable_encoder(folder_id)}/upload",
291
+ method="POST",
292
+ params={
293
+ "duplicate_handling": duplicate_handling,
294
+ },
295
+ data={},
296
+ files={
297
+ "file": file,
298
+ },
299
+ request_options=request_options,
300
+ omit=OMIT,
301
+ )
302
+ try:
303
+ if 200 <= _response.status_code < 300:
304
+ return typing.cast(
305
+ FileMetadata,
306
+ construct_type(
307
+ type_=FileMetadata, # type: ignore
308
+ object_=_response.json(),
309
+ ),
310
+ )
311
+ if _response.status_code == 422:
312
+ raise UnprocessableEntityError(
313
+ typing.cast(
314
+ HttpValidationError,
315
+ construct_type(
316
+ type_=HttpValidationError, # type: ignore
317
+ object_=_response.json(),
318
+ ),
319
+ )
320
+ )
321
+ _response_json = _response.json()
322
+ except JSONDecodeError:
323
+ raise ApiError(status_code=_response.status_code, body=_response.text)
324
+ raise ApiError(status_code=_response.status_code, body=_response_json)
325
+
326
+ async def list(
327
+ self,
328
+ folder_id: str,
329
+ *,
330
+ limit: typing.Optional[int] = None,
331
+ after: typing.Optional[str] = None,
332
+ include_content: typing.Optional[bool] = None,
333
+ request_options: typing.Optional[RequestOptions] = None,
334
+ ) -> typing.List[FileMetadata]:
335
+ """
336
+ List paginated files associated with a data folder.
337
+
338
+ Parameters
339
+ ----------
340
+ folder_id : str
341
+
342
+ limit : typing.Optional[int]
343
+ Number of files to return
344
+
345
+ after : typing.Optional[str]
346
+ Pagination cursor to fetch the next set of results
347
+
348
+ include_content : typing.Optional[bool]
349
+ Whether to include full file content
350
+
351
+ request_options : typing.Optional[RequestOptions]
352
+ Request-specific configuration.
353
+
354
+ Returns
355
+ -------
356
+ typing.List[FileMetadata]
357
+ Successful Response
358
+
359
+ Examples
360
+ --------
361
+ import asyncio
362
+
363
+ from letta_client import AsyncLetta
364
+
365
+ client = AsyncLetta(
366
+ project="YOUR_PROJECT",
367
+ token="YOUR_TOKEN",
368
+ )
369
+
370
+
371
+ async def main() -> None:
372
+ await client.folders.files.list(
373
+ folder_id="folder_id",
374
+ )
375
+
376
+
377
+ asyncio.run(main())
378
+ """
379
+ _response = await self._client_wrapper.httpx_client.request(
380
+ f"v1/folders/{jsonable_encoder(folder_id)}/files",
381
+ method="GET",
382
+ params={
383
+ "limit": limit,
384
+ "after": after,
385
+ "include_content": include_content,
386
+ },
387
+ request_options=request_options,
388
+ )
389
+ try:
390
+ if 200 <= _response.status_code < 300:
391
+ return typing.cast(
392
+ typing.List[FileMetadata],
393
+ construct_type(
394
+ type_=typing.List[FileMetadata], # type: ignore
395
+ object_=_response.json(),
396
+ ),
397
+ )
398
+ if _response.status_code == 422:
399
+ raise UnprocessableEntityError(
400
+ typing.cast(
401
+ HttpValidationError,
402
+ construct_type(
403
+ type_=HttpValidationError, # type: ignore
404
+ object_=_response.json(),
405
+ ),
406
+ )
407
+ )
408
+ _response_json = _response.json()
409
+ except JSONDecodeError:
410
+ raise ApiError(status_code=_response.status_code, body=_response.text)
411
+ raise ApiError(status_code=_response.status_code, body=_response_json)
412
+
413
+ async def delete(
414
+ self, folder_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
415
+ ) -> None:
416
+ """
417
+ Delete a file from a folder.
418
+
419
+ Parameters
420
+ ----------
421
+ folder_id : str
422
+
423
+ file_id : str
424
+
425
+ request_options : typing.Optional[RequestOptions]
426
+ Request-specific configuration.
427
+
428
+ Returns
429
+ -------
430
+ None
431
+
432
+ Examples
433
+ --------
434
+ import asyncio
435
+
436
+ from letta_client import AsyncLetta
437
+
438
+ client = AsyncLetta(
439
+ project="YOUR_PROJECT",
440
+ token="YOUR_TOKEN",
441
+ )
442
+
443
+
444
+ async def main() -> None:
445
+ await client.folders.files.delete(
446
+ folder_id="folder_id",
447
+ file_id="file_id",
448
+ )
449
+
450
+
451
+ asyncio.run(main())
452
+ """
453
+ _response = await self._client_wrapper.httpx_client.request(
454
+ f"v1/folders/{jsonable_encoder(folder_id)}/{jsonable_encoder(file_id)}",
455
+ method="DELETE",
456
+ request_options=request_options,
457
+ )
458
+ try:
459
+ if 200 <= _response.status_code < 300:
460
+ return
461
+ if _response.status_code == 422:
462
+ raise UnprocessableEntityError(
463
+ typing.cast(
464
+ HttpValidationError,
465
+ construct_type(
466
+ type_=HttpValidationError, # type: ignore
467
+ object_=_response.json(),
468
+ ),
469
+ )
470
+ )
471
+ _response_json = _response.json()
472
+ except JSONDecodeError:
473
+ raise ApiError(status_code=_response.status_code, body=_response.text)
474
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,189 @@
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 ...types.passage import Passage
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
11
+ from json.decoder import JSONDecodeError
12
+ from ...core.api_error import ApiError
13
+ from ...core.client_wrapper import AsyncClientWrapper
14
+
15
+
16
+ class PassagesClient:
17
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
18
+ self._client_wrapper = client_wrapper
19
+
20
+ def list(
21
+ self,
22
+ folder_id: str,
23
+ *,
24
+ after: typing.Optional[str] = None,
25
+ before: typing.Optional[str] = None,
26
+ limit: typing.Optional[int] = None,
27
+ request_options: typing.Optional[RequestOptions] = None,
28
+ ) -> typing.List[Passage]:
29
+ """
30
+ List all passages associated with a data folder.
31
+
32
+ Parameters
33
+ ----------
34
+ folder_id : str
35
+
36
+ after : typing.Optional[str]
37
+ Message after which to retrieve the returned messages.
38
+
39
+ before : typing.Optional[str]
40
+ Message before which to retrieve the returned messages.
41
+
42
+ limit : typing.Optional[int]
43
+ Maximum number of messages to retrieve.
44
+
45
+ request_options : typing.Optional[RequestOptions]
46
+ Request-specific configuration.
47
+
48
+ Returns
49
+ -------
50
+ typing.List[Passage]
51
+ Successful Response
52
+
53
+ Examples
54
+ --------
55
+ from letta_client import Letta
56
+
57
+ client = Letta(
58
+ project="YOUR_PROJECT",
59
+ token="YOUR_TOKEN",
60
+ )
61
+ client.folders.passages.list(
62
+ folder_id="folder_id",
63
+ )
64
+ """
65
+ _response = self._client_wrapper.httpx_client.request(
66
+ f"v1/folders/{jsonable_encoder(folder_id)}/passages",
67
+ method="GET",
68
+ params={
69
+ "after": after,
70
+ "before": before,
71
+ "limit": limit,
72
+ },
73
+ request_options=request_options,
74
+ )
75
+ try:
76
+ if 200 <= _response.status_code < 300:
77
+ return typing.cast(
78
+ typing.List[Passage],
79
+ construct_type(
80
+ type_=typing.List[Passage], # type: ignore
81
+ object_=_response.json(),
82
+ ),
83
+ )
84
+ if _response.status_code == 422:
85
+ raise UnprocessableEntityError(
86
+ typing.cast(
87
+ HttpValidationError,
88
+ construct_type(
89
+ type_=HttpValidationError, # type: ignore
90
+ object_=_response.json(),
91
+ ),
92
+ )
93
+ )
94
+ _response_json = _response.json()
95
+ except JSONDecodeError:
96
+ raise ApiError(status_code=_response.status_code, body=_response.text)
97
+ raise ApiError(status_code=_response.status_code, body=_response_json)
98
+
99
+
100
+ class AsyncPassagesClient:
101
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
102
+ self._client_wrapper = client_wrapper
103
+
104
+ async def list(
105
+ self,
106
+ folder_id: str,
107
+ *,
108
+ after: typing.Optional[str] = None,
109
+ before: typing.Optional[str] = None,
110
+ limit: typing.Optional[int] = None,
111
+ request_options: typing.Optional[RequestOptions] = None,
112
+ ) -> typing.List[Passage]:
113
+ """
114
+ List all passages associated with a data folder.
115
+
116
+ Parameters
117
+ ----------
118
+ folder_id : str
119
+
120
+ after : typing.Optional[str]
121
+ Message after which to retrieve the returned messages.
122
+
123
+ before : typing.Optional[str]
124
+ Message before which to retrieve the returned messages.
125
+
126
+ limit : typing.Optional[int]
127
+ Maximum number of messages to retrieve.
128
+
129
+ request_options : typing.Optional[RequestOptions]
130
+ Request-specific configuration.
131
+
132
+ Returns
133
+ -------
134
+ typing.List[Passage]
135
+ Successful Response
136
+
137
+ Examples
138
+ --------
139
+ import asyncio
140
+
141
+ from letta_client import AsyncLetta
142
+
143
+ client = AsyncLetta(
144
+ project="YOUR_PROJECT",
145
+ token="YOUR_TOKEN",
146
+ )
147
+
148
+
149
+ async def main() -> None:
150
+ await client.folders.passages.list(
151
+ folder_id="folder_id",
152
+ )
153
+
154
+
155
+ asyncio.run(main())
156
+ """
157
+ _response = await self._client_wrapper.httpx_client.request(
158
+ f"v1/folders/{jsonable_encoder(folder_id)}/passages",
159
+ method="GET",
160
+ params={
161
+ "after": after,
162
+ "before": before,
163
+ "limit": limit,
164
+ },
165
+ request_options=request_options,
166
+ )
167
+ try:
168
+ if 200 <= _response.status_code < 300:
169
+ return typing.cast(
170
+ typing.List[Passage],
171
+ construct_type(
172
+ type_=typing.List[Passage], # type: ignore
173
+ object_=_response.json(),
174
+ ),
175
+ )
176
+ if _response.status_code == 422:
177
+ raise UnprocessableEntityError(
178
+ typing.cast(
179
+ HttpValidationError,
180
+ construct_type(
181
+ type_=HttpValidationError, # type: ignore
182
+ object_=_response.json(),
183
+ ),
184
+ )
185
+ )
186
+ _response_json = _response.json()
187
+ except JSONDecodeError:
188
+ raise ApiError(status_code=_response.status_code, body=_response.text)
189
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: letta-client
3
- Version: 0.1.217
3
+ Version: 0.1.219
4
4
  Summary:
5
5
  Requires-Python: >=3.8,<4.0
6
6
  Classifier: Intended Audience :: Developers