letta-client 0.1.217__py3-none-any.whl → 0.1.218__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.218.dist-info}/METADATA +1 -1
- {letta_client-0.1.217.dist-info → letta_client-0.1.218.dist-info}/RECORD +16 -8
- {letta_client-0.1.217.dist-info → letta_client-0.1.218.dist-info}/WHEEL +0 -0
letta_client/folders/client.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
4
|
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from .files.client import FilesClient
|
|
6
|
+
from .passages.client import PassagesClient
|
|
5
7
|
from ..core.request_options import RequestOptions
|
|
6
8
|
from ..core.unchecked_base_model import construct_type
|
|
7
9
|
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
@@ -13,11 +15,9 @@ from ..core.jsonable_encoder import jsonable_encoder
|
|
|
13
15
|
from ..types.embedding_config import EmbeddingConfig
|
|
14
16
|
from ..core.serialization import convert_and_respect_annotation_metadata
|
|
15
17
|
from ..types.organization_sources_stats import OrganizationSourcesStats
|
|
16
|
-
from .. import core
|
|
17
|
-
from ..types.duplicate_file_handling import DuplicateFileHandling
|
|
18
|
-
from ..types.file_metadata import FileMetadata
|
|
19
|
-
from ..types.passage import Passage
|
|
20
18
|
from ..core.client_wrapper import AsyncClientWrapper
|
|
19
|
+
from .files.client import AsyncFilesClient
|
|
20
|
+
from .passages.client import AsyncPassagesClient
|
|
21
21
|
|
|
22
22
|
# this is used as the default value for optional parameters
|
|
23
23
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -26,8 +26,10 @@ OMIT = typing.cast(typing.Any, ...)
|
|
|
26
26
|
class FoldersClient:
|
|
27
27
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
28
28
|
self._client_wrapper = client_wrapper
|
|
29
|
+
self.files = FilesClient(client_wrapper=self._client_wrapper)
|
|
30
|
+
self.passages = PassagesClient(client_wrapper=self._client_wrapper)
|
|
29
31
|
|
|
30
|
-
def
|
|
32
|
+
def count(self, *, request_options: typing.Optional[RequestOptions] = None) -> int:
|
|
31
33
|
"""
|
|
32
34
|
Count all data folders created by a user.
|
|
33
35
|
|
|
@@ -49,7 +51,7 @@ class FoldersClient:
|
|
|
49
51
|
project="YOUR_PROJECT",
|
|
50
52
|
token="YOUR_TOKEN",
|
|
51
53
|
)
|
|
52
|
-
client.folders.
|
|
54
|
+
client.folders.count()
|
|
53
55
|
"""
|
|
54
56
|
_response = self._client_wrapper.httpx_client.request(
|
|
55
57
|
"v1/folders/count",
|
|
@@ -80,7 +82,7 @@ class FoldersClient:
|
|
|
80
82
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
81
83
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
82
84
|
|
|
83
|
-
def
|
|
85
|
+
def retrieve(self, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Folder:
|
|
84
86
|
"""
|
|
85
87
|
Get a folder by ID
|
|
86
88
|
|
|
@@ -104,7 +106,7 @@ class FoldersClient:
|
|
|
104
106
|
project="YOUR_PROJECT",
|
|
105
107
|
token="YOUR_TOKEN",
|
|
106
108
|
)
|
|
107
|
-
client.folders.
|
|
109
|
+
client.folders.retrieve(
|
|
108
110
|
folder_id="folder_id",
|
|
109
111
|
)
|
|
110
112
|
"""
|
|
@@ -137,7 +139,7 @@ class FoldersClient:
|
|
|
137
139
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
138
140
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
139
141
|
|
|
140
|
-
def
|
|
142
|
+
def delete(
|
|
141
143
|
self, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
142
144
|
) -> typing.Optional[typing.Any]:
|
|
143
145
|
"""
|
|
@@ -163,7 +165,7 @@ class FoldersClient:
|
|
|
163
165
|
project="YOUR_PROJECT",
|
|
164
166
|
token="YOUR_TOKEN",
|
|
165
167
|
)
|
|
166
|
-
client.folders.
|
|
168
|
+
client.folders.delete(
|
|
167
169
|
folder_id="folder_id",
|
|
168
170
|
)
|
|
169
171
|
"""
|
|
@@ -196,7 +198,7 @@ class FoldersClient:
|
|
|
196
198
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
197
199
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
198
200
|
|
|
199
|
-
def
|
|
201
|
+
def modify(
|
|
200
202
|
self,
|
|
201
203
|
folder_id: str,
|
|
202
204
|
*,
|
|
@@ -245,7 +247,7 @@ class FoldersClient:
|
|
|
245
247
|
project="YOUR_PROJECT",
|
|
246
248
|
token="YOUR_TOKEN",
|
|
247
249
|
)
|
|
248
|
-
client.folders.
|
|
250
|
+
client.folders.modify(
|
|
249
251
|
folder_id="folder_id",
|
|
250
252
|
)
|
|
251
253
|
"""
|
|
@@ -291,9 +293,7 @@ class FoldersClient:
|
|
|
291
293
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
292
294
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
293
295
|
|
|
294
|
-
def
|
|
295
|
-
self, folder_name: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
296
|
-
) -> str:
|
|
296
|
+
def retrieve_by_name(self, folder_name: str, *, request_options: typing.Optional[RequestOptions] = None) -> str:
|
|
297
297
|
"""
|
|
298
298
|
Get a folder by name
|
|
299
299
|
|
|
@@ -317,7 +317,7 @@ class FoldersClient:
|
|
|
317
317
|
project="YOUR_PROJECT",
|
|
318
318
|
token="YOUR_TOKEN",
|
|
319
319
|
)
|
|
320
|
-
client.folders.
|
|
320
|
+
client.folders.retrieve_by_name(
|
|
321
321
|
folder_name="folder_name",
|
|
322
322
|
)
|
|
323
323
|
"""
|
|
@@ -419,7 +419,7 @@ class FoldersClient:
|
|
|
419
419
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
420
420
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
421
421
|
|
|
422
|
-
def
|
|
422
|
+
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Folder]:
|
|
423
423
|
"""
|
|
424
424
|
List all data folders created by a user.
|
|
425
425
|
|
|
@@ -441,7 +441,7 @@ class FoldersClient:
|
|
|
441
441
|
project="YOUR_PROJECT",
|
|
442
442
|
token="YOUR_TOKEN",
|
|
443
443
|
)
|
|
444
|
-
client.folders.
|
|
444
|
+
client.folders.list()
|
|
445
445
|
"""
|
|
446
446
|
_response = self._client_wrapper.httpx_client.request(
|
|
447
447
|
"v1/folders/",
|
|
@@ -472,7 +472,7 @@ class FoldersClient:
|
|
|
472
472
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
473
473
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
474
474
|
|
|
475
|
-
def
|
|
475
|
+
def create(
|
|
476
476
|
self,
|
|
477
477
|
*,
|
|
478
478
|
name: str,
|
|
@@ -526,7 +526,7 @@ class FoldersClient:
|
|
|
526
526
|
project="YOUR_PROJECT",
|
|
527
527
|
token="YOUR_TOKEN",
|
|
528
528
|
)
|
|
529
|
-
client.folders.
|
|
529
|
+
client.folders.create(
|
|
530
530
|
name="name",
|
|
531
531
|
)
|
|
532
532
|
"""
|
|
@@ -574,84 +574,6 @@ class FoldersClient:
|
|
|
574
574
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
575
575
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
576
576
|
|
|
577
|
-
def upload_file_to_folder(
|
|
578
|
-
self,
|
|
579
|
-
folder_id: str,
|
|
580
|
-
*,
|
|
581
|
-
file: core.File,
|
|
582
|
-
duplicate_handling: typing.Optional[DuplicateFileHandling] = None,
|
|
583
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
584
|
-
) -> FileMetadata:
|
|
585
|
-
"""
|
|
586
|
-
Upload a file to a data folder.
|
|
587
|
-
|
|
588
|
-
Parameters
|
|
589
|
-
----------
|
|
590
|
-
folder_id : str
|
|
591
|
-
|
|
592
|
-
file : core.File
|
|
593
|
-
See core.File for more documentation
|
|
594
|
-
|
|
595
|
-
duplicate_handling : typing.Optional[DuplicateFileHandling]
|
|
596
|
-
How to handle duplicate filenames
|
|
597
|
-
|
|
598
|
-
request_options : typing.Optional[RequestOptions]
|
|
599
|
-
Request-specific configuration.
|
|
600
|
-
|
|
601
|
-
Returns
|
|
602
|
-
-------
|
|
603
|
-
FileMetadata
|
|
604
|
-
Successful Response
|
|
605
|
-
|
|
606
|
-
Examples
|
|
607
|
-
--------
|
|
608
|
-
from letta_client import Letta
|
|
609
|
-
|
|
610
|
-
client = Letta(
|
|
611
|
-
project="YOUR_PROJECT",
|
|
612
|
-
token="YOUR_TOKEN",
|
|
613
|
-
)
|
|
614
|
-
client.folders.upload_file_to_folder(
|
|
615
|
-
folder_id="folder_id",
|
|
616
|
-
)
|
|
617
|
-
"""
|
|
618
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
619
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/upload",
|
|
620
|
-
method="POST",
|
|
621
|
-
params={
|
|
622
|
-
"duplicate_handling": duplicate_handling,
|
|
623
|
-
},
|
|
624
|
-
data={},
|
|
625
|
-
files={
|
|
626
|
-
"file": file,
|
|
627
|
-
},
|
|
628
|
-
request_options=request_options,
|
|
629
|
-
omit=OMIT,
|
|
630
|
-
)
|
|
631
|
-
try:
|
|
632
|
-
if 200 <= _response.status_code < 300:
|
|
633
|
-
return typing.cast(
|
|
634
|
-
FileMetadata,
|
|
635
|
-
construct_type(
|
|
636
|
-
type_=FileMetadata, # type: ignore
|
|
637
|
-
object_=_response.json(),
|
|
638
|
-
),
|
|
639
|
-
)
|
|
640
|
-
if _response.status_code == 422:
|
|
641
|
-
raise UnprocessableEntityError(
|
|
642
|
-
typing.cast(
|
|
643
|
-
HttpValidationError,
|
|
644
|
-
construct_type(
|
|
645
|
-
type_=HttpValidationError, # type: ignore
|
|
646
|
-
object_=_response.json(),
|
|
647
|
-
),
|
|
648
|
-
)
|
|
649
|
-
)
|
|
650
|
-
_response_json = _response.json()
|
|
651
|
-
except JSONDecodeError:
|
|
652
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
653
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
654
|
-
|
|
655
577
|
def get_agents_for_folder(
|
|
656
578
|
self, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
657
579
|
) -> typing.List[str]:
|
|
@@ -711,225 +633,14 @@ class FoldersClient:
|
|
|
711
633
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
712
634
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
713
635
|
|
|
714
|
-
def list_folder_passages(
|
|
715
|
-
self,
|
|
716
|
-
folder_id: str,
|
|
717
|
-
*,
|
|
718
|
-
after: typing.Optional[str] = None,
|
|
719
|
-
before: typing.Optional[str] = None,
|
|
720
|
-
limit: typing.Optional[int] = None,
|
|
721
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
722
|
-
) -> typing.List[Passage]:
|
|
723
|
-
"""
|
|
724
|
-
List all passages associated with a data folder.
|
|
725
|
-
|
|
726
|
-
Parameters
|
|
727
|
-
----------
|
|
728
|
-
folder_id : str
|
|
729
|
-
|
|
730
|
-
after : typing.Optional[str]
|
|
731
|
-
Message after which to retrieve the returned messages.
|
|
732
|
-
|
|
733
|
-
before : typing.Optional[str]
|
|
734
|
-
Message before which to retrieve the returned messages.
|
|
735
|
-
|
|
736
|
-
limit : typing.Optional[int]
|
|
737
|
-
Maximum number of messages to retrieve.
|
|
738
|
-
|
|
739
|
-
request_options : typing.Optional[RequestOptions]
|
|
740
|
-
Request-specific configuration.
|
|
741
|
-
|
|
742
|
-
Returns
|
|
743
|
-
-------
|
|
744
|
-
typing.List[Passage]
|
|
745
|
-
Successful Response
|
|
746
|
-
|
|
747
|
-
Examples
|
|
748
|
-
--------
|
|
749
|
-
from letta_client import Letta
|
|
750
|
-
|
|
751
|
-
client = Letta(
|
|
752
|
-
project="YOUR_PROJECT",
|
|
753
|
-
token="YOUR_TOKEN",
|
|
754
|
-
)
|
|
755
|
-
client.folders.list_folder_passages(
|
|
756
|
-
folder_id="folder_id",
|
|
757
|
-
)
|
|
758
|
-
"""
|
|
759
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
760
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/passages",
|
|
761
|
-
method="GET",
|
|
762
|
-
params={
|
|
763
|
-
"after": after,
|
|
764
|
-
"before": before,
|
|
765
|
-
"limit": limit,
|
|
766
|
-
},
|
|
767
|
-
request_options=request_options,
|
|
768
|
-
)
|
|
769
|
-
try:
|
|
770
|
-
if 200 <= _response.status_code < 300:
|
|
771
|
-
return typing.cast(
|
|
772
|
-
typing.List[Passage],
|
|
773
|
-
construct_type(
|
|
774
|
-
type_=typing.List[Passage], # type: ignore
|
|
775
|
-
object_=_response.json(),
|
|
776
|
-
),
|
|
777
|
-
)
|
|
778
|
-
if _response.status_code == 422:
|
|
779
|
-
raise UnprocessableEntityError(
|
|
780
|
-
typing.cast(
|
|
781
|
-
HttpValidationError,
|
|
782
|
-
construct_type(
|
|
783
|
-
type_=HttpValidationError, # type: ignore
|
|
784
|
-
object_=_response.json(),
|
|
785
|
-
),
|
|
786
|
-
)
|
|
787
|
-
)
|
|
788
|
-
_response_json = _response.json()
|
|
789
|
-
except JSONDecodeError:
|
|
790
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
791
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
792
|
-
|
|
793
|
-
def list_folder_files(
|
|
794
|
-
self,
|
|
795
|
-
folder_id: str,
|
|
796
|
-
*,
|
|
797
|
-
limit: typing.Optional[int] = None,
|
|
798
|
-
after: typing.Optional[str] = None,
|
|
799
|
-
include_content: typing.Optional[bool] = None,
|
|
800
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
801
|
-
) -> typing.List[FileMetadata]:
|
|
802
|
-
"""
|
|
803
|
-
List paginated files associated with a data folder.
|
|
804
|
-
|
|
805
|
-
Parameters
|
|
806
|
-
----------
|
|
807
|
-
folder_id : str
|
|
808
|
-
|
|
809
|
-
limit : typing.Optional[int]
|
|
810
|
-
Number of files to return
|
|
811
|
-
|
|
812
|
-
after : typing.Optional[str]
|
|
813
|
-
Pagination cursor to fetch the next set of results
|
|
814
|
-
|
|
815
|
-
include_content : typing.Optional[bool]
|
|
816
|
-
Whether to include full file content
|
|
817
|
-
|
|
818
|
-
request_options : typing.Optional[RequestOptions]
|
|
819
|
-
Request-specific configuration.
|
|
820
|
-
|
|
821
|
-
Returns
|
|
822
|
-
-------
|
|
823
|
-
typing.List[FileMetadata]
|
|
824
|
-
Successful Response
|
|
825
|
-
|
|
826
|
-
Examples
|
|
827
|
-
--------
|
|
828
|
-
from letta_client import Letta
|
|
829
|
-
|
|
830
|
-
client = Letta(
|
|
831
|
-
project="YOUR_PROJECT",
|
|
832
|
-
token="YOUR_TOKEN",
|
|
833
|
-
)
|
|
834
|
-
client.folders.list_folder_files(
|
|
835
|
-
folder_id="folder_id",
|
|
836
|
-
)
|
|
837
|
-
"""
|
|
838
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
839
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/files",
|
|
840
|
-
method="GET",
|
|
841
|
-
params={
|
|
842
|
-
"limit": limit,
|
|
843
|
-
"after": after,
|
|
844
|
-
"include_content": include_content,
|
|
845
|
-
},
|
|
846
|
-
request_options=request_options,
|
|
847
|
-
)
|
|
848
|
-
try:
|
|
849
|
-
if 200 <= _response.status_code < 300:
|
|
850
|
-
return typing.cast(
|
|
851
|
-
typing.List[FileMetadata],
|
|
852
|
-
construct_type(
|
|
853
|
-
type_=typing.List[FileMetadata], # type: ignore
|
|
854
|
-
object_=_response.json(),
|
|
855
|
-
),
|
|
856
|
-
)
|
|
857
|
-
if _response.status_code == 422:
|
|
858
|
-
raise UnprocessableEntityError(
|
|
859
|
-
typing.cast(
|
|
860
|
-
HttpValidationError,
|
|
861
|
-
construct_type(
|
|
862
|
-
type_=HttpValidationError, # type: ignore
|
|
863
|
-
object_=_response.json(),
|
|
864
|
-
),
|
|
865
|
-
)
|
|
866
|
-
)
|
|
867
|
-
_response_json = _response.json()
|
|
868
|
-
except JSONDecodeError:
|
|
869
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
870
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
871
|
-
|
|
872
|
-
def delete_file_from_folder(
|
|
873
|
-
self, folder_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
874
|
-
) -> None:
|
|
875
|
-
"""
|
|
876
|
-
Delete a file from a folder.
|
|
877
|
-
|
|
878
|
-
Parameters
|
|
879
|
-
----------
|
|
880
|
-
folder_id : str
|
|
881
|
-
|
|
882
|
-
file_id : str
|
|
883
|
-
|
|
884
|
-
request_options : typing.Optional[RequestOptions]
|
|
885
|
-
Request-specific configuration.
|
|
886
|
-
|
|
887
|
-
Returns
|
|
888
|
-
-------
|
|
889
|
-
None
|
|
890
|
-
|
|
891
|
-
Examples
|
|
892
|
-
--------
|
|
893
|
-
from letta_client import Letta
|
|
894
|
-
|
|
895
|
-
client = Letta(
|
|
896
|
-
project="YOUR_PROJECT",
|
|
897
|
-
token="YOUR_TOKEN",
|
|
898
|
-
)
|
|
899
|
-
client.folders.delete_file_from_folder(
|
|
900
|
-
folder_id="folder_id",
|
|
901
|
-
file_id="file_id",
|
|
902
|
-
)
|
|
903
|
-
"""
|
|
904
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
905
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/{jsonable_encoder(file_id)}",
|
|
906
|
-
method="DELETE",
|
|
907
|
-
request_options=request_options,
|
|
908
|
-
)
|
|
909
|
-
try:
|
|
910
|
-
if 200 <= _response.status_code < 300:
|
|
911
|
-
return
|
|
912
|
-
if _response.status_code == 422:
|
|
913
|
-
raise UnprocessableEntityError(
|
|
914
|
-
typing.cast(
|
|
915
|
-
HttpValidationError,
|
|
916
|
-
construct_type(
|
|
917
|
-
type_=HttpValidationError, # type: ignore
|
|
918
|
-
object_=_response.json(),
|
|
919
|
-
),
|
|
920
|
-
)
|
|
921
|
-
)
|
|
922
|
-
_response_json = _response.json()
|
|
923
|
-
except JSONDecodeError:
|
|
924
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
925
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
926
|
-
|
|
927
636
|
|
|
928
637
|
class AsyncFoldersClient:
|
|
929
638
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
930
639
|
self._client_wrapper = client_wrapper
|
|
640
|
+
self.files = AsyncFilesClient(client_wrapper=self._client_wrapper)
|
|
641
|
+
self.passages = AsyncPassagesClient(client_wrapper=self._client_wrapper)
|
|
931
642
|
|
|
932
|
-
async def
|
|
643
|
+
async def count(self, *, request_options: typing.Optional[RequestOptions] = None) -> int:
|
|
933
644
|
"""
|
|
934
645
|
Count all data folders created by a user.
|
|
935
646
|
|
|
@@ -956,7 +667,7 @@ class AsyncFoldersClient:
|
|
|
956
667
|
|
|
957
668
|
|
|
958
669
|
async def main() -> None:
|
|
959
|
-
await client.folders.
|
|
670
|
+
await client.folders.count()
|
|
960
671
|
|
|
961
672
|
|
|
962
673
|
asyncio.run(main())
|
|
@@ -990,9 +701,7 @@ class AsyncFoldersClient:
|
|
|
990
701
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
991
702
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
992
703
|
|
|
993
|
-
async def
|
|
994
|
-
self, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
995
|
-
) -> Folder:
|
|
704
|
+
async def retrieve(self, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Folder:
|
|
996
705
|
"""
|
|
997
706
|
Get a folder by ID
|
|
998
707
|
|
|
@@ -1021,7 +730,7 @@ class AsyncFoldersClient:
|
|
|
1021
730
|
|
|
1022
731
|
|
|
1023
732
|
async def main() -> None:
|
|
1024
|
-
await client.folders.
|
|
733
|
+
await client.folders.retrieve(
|
|
1025
734
|
folder_id="folder_id",
|
|
1026
735
|
)
|
|
1027
736
|
|
|
@@ -1057,7 +766,7 @@ class AsyncFoldersClient:
|
|
|
1057
766
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1058
767
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1059
768
|
|
|
1060
|
-
async def
|
|
769
|
+
async def delete(
|
|
1061
770
|
self, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1062
771
|
) -> typing.Optional[typing.Any]:
|
|
1063
772
|
"""
|
|
@@ -1088,7 +797,7 @@ class AsyncFoldersClient:
|
|
|
1088
797
|
|
|
1089
798
|
|
|
1090
799
|
async def main() -> None:
|
|
1091
|
-
await client.folders.
|
|
800
|
+
await client.folders.delete(
|
|
1092
801
|
folder_id="folder_id",
|
|
1093
802
|
)
|
|
1094
803
|
|
|
@@ -1124,7 +833,7 @@ class AsyncFoldersClient:
|
|
|
1124
833
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1125
834
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1126
835
|
|
|
1127
|
-
async def
|
|
836
|
+
async def modify(
|
|
1128
837
|
self,
|
|
1129
838
|
folder_id: str,
|
|
1130
839
|
*,
|
|
@@ -1178,7 +887,7 @@ class AsyncFoldersClient:
|
|
|
1178
887
|
|
|
1179
888
|
|
|
1180
889
|
async def main() -> None:
|
|
1181
|
-
await client.folders.
|
|
890
|
+
await client.folders.modify(
|
|
1182
891
|
folder_id="folder_id",
|
|
1183
892
|
)
|
|
1184
893
|
|
|
@@ -1227,7 +936,7 @@ class AsyncFoldersClient:
|
|
|
1227
936
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1228
937
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1229
938
|
|
|
1230
|
-
async def
|
|
939
|
+
async def retrieve_by_name(
|
|
1231
940
|
self, folder_name: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1232
941
|
) -> str:
|
|
1233
942
|
"""
|
|
@@ -1258,7 +967,7 @@ class AsyncFoldersClient:
|
|
|
1258
967
|
|
|
1259
968
|
|
|
1260
969
|
async def main() -> None:
|
|
1261
|
-
await client.folders.
|
|
970
|
+
await client.folders.retrieve_by_name(
|
|
1262
971
|
folder_name="folder_name",
|
|
1263
972
|
)
|
|
1264
973
|
|
|
@@ -1371,7 +1080,7 @@ class AsyncFoldersClient:
|
|
|
1371
1080
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1372
1081
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1373
1082
|
|
|
1374
|
-
async def
|
|
1083
|
+
async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Folder]:
|
|
1375
1084
|
"""
|
|
1376
1085
|
List all data folders created by a user.
|
|
1377
1086
|
|
|
@@ -1398,7 +1107,7 @@ class AsyncFoldersClient:
|
|
|
1398
1107
|
|
|
1399
1108
|
|
|
1400
1109
|
async def main() -> None:
|
|
1401
|
-
await client.folders.
|
|
1110
|
+
await client.folders.list()
|
|
1402
1111
|
|
|
1403
1112
|
|
|
1404
1113
|
asyncio.run(main())
|
|
@@ -1432,7 +1141,7 @@ class AsyncFoldersClient:
|
|
|
1432
1141
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1433
1142
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1434
1143
|
|
|
1435
|
-
async def
|
|
1144
|
+
async def create(
|
|
1436
1145
|
self,
|
|
1437
1146
|
*,
|
|
1438
1147
|
name: str,
|
|
@@ -1491,7 +1200,7 @@ class AsyncFoldersClient:
|
|
|
1491
1200
|
|
|
1492
1201
|
|
|
1493
1202
|
async def main() -> None:
|
|
1494
|
-
await client.folders.
|
|
1203
|
+
await client.folders.create(
|
|
1495
1204
|
name="name",
|
|
1496
1205
|
)
|
|
1497
1206
|
|
|
@@ -1542,92 +1251,6 @@ class AsyncFoldersClient:
|
|
|
1542
1251
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1543
1252
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1544
1253
|
|
|
1545
|
-
async def upload_file_to_folder(
|
|
1546
|
-
self,
|
|
1547
|
-
folder_id: str,
|
|
1548
|
-
*,
|
|
1549
|
-
file: core.File,
|
|
1550
|
-
duplicate_handling: typing.Optional[DuplicateFileHandling] = None,
|
|
1551
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1552
|
-
) -> FileMetadata:
|
|
1553
|
-
"""
|
|
1554
|
-
Upload a file to a data folder.
|
|
1555
|
-
|
|
1556
|
-
Parameters
|
|
1557
|
-
----------
|
|
1558
|
-
folder_id : str
|
|
1559
|
-
|
|
1560
|
-
file : core.File
|
|
1561
|
-
See core.File for more documentation
|
|
1562
|
-
|
|
1563
|
-
duplicate_handling : typing.Optional[DuplicateFileHandling]
|
|
1564
|
-
How to handle duplicate filenames
|
|
1565
|
-
|
|
1566
|
-
request_options : typing.Optional[RequestOptions]
|
|
1567
|
-
Request-specific configuration.
|
|
1568
|
-
|
|
1569
|
-
Returns
|
|
1570
|
-
-------
|
|
1571
|
-
FileMetadata
|
|
1572
|
-
Successful Response
|
|
1573
|
-
|
|
1574
|
-
Examples
|
|
1575
|
-
--------
|
|
1576
|
-
import asyncio
|
|
1577
|
-
|
|
1578
|
-
from letta_client import AsyncLetta
|
|
1579
|
-
|
|
1580
|
-
client = AsyncLetta(
|
|
1581
|
-
project="YOUR_PROJECT",
|
|
1582
|
-
token="YOUR_TOKEN",
|
|
1583
|
-
)
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
async def main() -> None:
|
|
1587
|
-
await client.folders.upload_file_to_folder(
|
|
1588
|
-
folder_id="folder_id",
|
|
1589
|
-
)
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
asyncio.run(main())
|
|
1593
|
-
"""
|
|
1594
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1595
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/upload",
|
|
1596
|
-
method="POST",
|
|
1597
|
-
params={
|
|
1598
|
-
"duplicate_handling": duplicate_handling,
|
|
1599
|
-
},
|
|
1600
|
-
data={},
|
|
1601
|
-
files={
|
|
1602
|
-
"file": file,
|
|
1603
|
-
},
|
|
1604
|
-
request_options=request_options,
|
|
1605
|
-
omit=OMIT,
|
|
1606
|
-
)
|
|
1607
|
-
try:
|
|
1608
|
-
if 200 <= _response.status_code < 300:
|
|
1609
|
-
return typing.cast(
|
|
1610
|
-
FileMetadata,
|
|
1611
|
-
construct_type(
|
|
1612
|
-
type_=FileMetadata, # type: ignore
|
|
1613
|
-
object_=_response.json(),
|
|
1614
|
-
),
|
|
1615
|
-
)
|
|
1616
|
-
if _response.status_code == 422:
|
|
1617
|
-
raise UnprocessableEntityError(
|
|
1618
|
-
typing.cast(
|
|
1619
|
-
HttpValidationError,
|
|
1620
|
-
construct_type(
|
|
1621
|
-
type_=HttpValidationError, # type: ignore
|
|
1622
|
-
object_=_response.json(),
|
|
1623
|
-
),
|
|
1624
|
-
)
|
|
1625
|
-
)
|
|
1626
|
-
_response_json = _response.json()
|
|
1627
|
-
except JSONDecodeError:
|
|
1628
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1629
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1630
|
-
|
|
1631
1254
|
async def get_agents_for_folder(
|
|
1632
1255
|
self, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1633
1256
|
) -> typing.List[str]:
|
|
@@ -1694,240 +1317,3 @@ class AsyncFoldersClient:
|
|
|
1694
1317
|
except JSONDecodeError:
|
|
1695
1318
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1696
1319
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1697
|
-
|
|
1698
|
-
async def list_folder_passages(
|
|
1699
|
-
self,
|
|
1700
|
-
folder_id: str,
|
|
1701
|
-
*,
|
|
1702
|
-
after: typing.Optional[str] = None,
|
|
1703
|
-
before: typing.Optional[str] = None,
|
|
1704
|
-
limit: typing.Optional[int] = None,
|
|
1705
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1706
|
-
) -> typing.List[Passage]:
|
|
1707
|
-
"""
|
|
1708
|
-
List all passages associated with a data folder.
|
|
1709
|
-
|
|
1710
|
-
Parameters
|
|
1711
|
-
----------
|
|
1712
|
-
folder_id : str
|
|
1713
|
-
|
|
1714
|
-
after : typing.Optional[str]
|
|
1715
|
-
Message after which to retrieve the returned messages.
|
|
1716
|
-
|
|
1717
|
-
before : typing.Optional[str]
|
|
1718
|
-
Message before which to retrieve the returned messages.
|
|
1719
|
-
|
|
1720
|
-
limit : typing.Optional[int]
|
|
1721
|
-
Maximum number of messages to retrieve.
|
|
1722
|
-
|
|
1723
|
-
request_options : typing.Optional[RequestOptions]
|
|
1724
|
-
Request-specific configuration.
|
|
1725
|
-
|
|
1726
|
-
Returns
|
|
1727
|
-
-------
|
|
1728
|
-
typing.List[Passage]
|
|
1729
|
-
Successful Response
|
|
1730
|
-
|
|
1731
|
-
Examples
|
|
1732
|
-
--------
|
|
1733
|
-
import asyncio
|
|
1734
|
-
|
|
1735
|
-
from letta_client import AsyncLetta
|
|
1736
|
-
|
|
1737
|
-
client = AsyncLetta(
|
|
1738
|
-
project="YOUR_PROJECT",
|
|
1739
|
-
token="YOUR_TOKEN",
|
|
1740
|
-
)
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
async def main() -> None:
|
|
1744
|
-
await client.folders.list_folder_passages(
|
|
1745
|
-
folder_id="folder_id",
|
|
1746
|
-
)
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
asyncio.run(main())
|
|
1750
|
-
"""
|
|
1751
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1752
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/passages",
|
|
1753
|
-
method="GET",
|
|
1754
|
-
params={
|
|
1755
|
-
"after": after,
|
|
1756
|
-
"before": before,
|
|
1757
|
-
"limit": limit,
|
|
1758
|
-
},
|
|
1759
|
-
request_options=request_options,
|
|
1760
|
-
)
|
|
1761
|
-
try:
|
|
1762
|
-
if 200 <= _response.status_code < 300:
|
|
1763
|
-
return typing.cast(
|
|
1764
|
-
typing.List[Passage],
|
|
1765
|
-
construct_type(
|
|
1766
|
-
type_=typing.List[Passage], # type: ignore
|
|
1767
|
-
object_=_response.json(),
|
|
1768
|
-
),
|
|
1769
|
-
)
|
|
1770
|
-
if _response.status_code == 422:
|
|
1771
|
-
raise UnprocessableEntityError(
|
|
1772
|
-
typing.cast(
|
|
1773
|
-
HttpValidationError,
|
|
1774
|
-
construct_type(
|
|
1775
|
-
type_=HttpValidationError, # type: ignore
|
|
1776
|
-
object_=_response.json(),
|
|
1777
|
-
),
|
|
1778
|
-
)
|
|
1779
|
-
)
|
|
1780
|
-
_response_json = _response.json()
|
|
1781
|
-
except JSONDecodeError:
|
|
1782
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1783
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1784
|
-
|
|
1785
|
-
async def list_folder_files(
|
|
1786
|
-
self,
|
|
1787
|
-
folder_id: str,
|
|
1788
|
-
*,
|
|
1789
|
-
limit: typing.Optional[int] = None,
|
|
1790
|
-
after: typing.Optional[str] = None,
|
|
1791
|
-
include_content: typing.Optional[bool] = None,
|
|
1792
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
1793
|
-
) -> typing.List[FileMetadata]:
|
|
1794
|
-
"""
|
|
1795
|
-
List paginated files associated with a data folder.
|
|
1796
|
-
|
|
1797
|
-
Parameters
|
|
1798
|
-
----------
|
|
1799
|
-
folder_id : str
|
|
1800
|
-
|
|
1801
|
-
limit : typing.Optional[int]
|
|
1802
|
-
Number of files to return
|
|
1803
|
-
|
|
1804
|
-
after : typing.Optional[str]
|
|
1805
|
-
Pagination cursor to fetch the next set of results
|
|
1806
|
-
|
|
1807
|
-
include_content : typing.Optional[bool]
|
|
1808
|
-
Whether to include full file content
|
|
1809
|
-
|
|
1810
|
-
request_options : typing.Optional[RequestOptions]
|
|
1811
|
-
Request-specific configuration.
|
|
1812
|
-
|
|
1813
|
-
Returns
|
|
1814
|
-
-------
|
|
1815
|
-
typing.List[FileMetadata]
|
|
1816
|
-
Successful Response
|
|
1817
|
-
|
|
1818
|
-
Examples
|
|
1819
|
-
--------
|
|
1820
|
-
import asyncio
|
|
1821
|
-
|
|
1822
|
-
from letta_client import AsyncLetta
|
|
1823
|
-
|
|
1824
|
-
client = AsyncLetta(
|
|
1825
|
-
project="YOUR_PROJECT",
|
|
1826
|
-
token="YOUR_TOKEN",
|
|
1827
|
-
)
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
async def main() -> None:
|
|
1831
|
-
await client.folders.list_folder_files(
|
|
1832
|
-
folder_id="folder_id",
|
|
1833
|
-
)
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
asyncio.run(main())
|
|
1837
|
-
"""
|
|
1838
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1839
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/files",
|
|
1840
|
-
method="GET",
|
|
1841
|
-
params={
|
|
1842
|
-
"limit": limit,
|
|
1843
|
-
"after": after,
|
|
1844
|
-
"include_content": include_content,
|
|
1845
|
-
},
|
|
1846
|
-
request_options=request_options,
|
|
1847
|
-
)
|
|
1848
|
-
try:
|
|
1849
|
-
if 200 <= _response.status_code < 300:
|
|
1850
|
-
return typing.cast(
|
|
1851
|
-
typing.List[FileMetadata],
|
|
1852
|
-
construct_type(
|
|
1853
|
-
type_=typing.List[FileMetadata], # type: ignore
|
|
1854
|
-
object_=_response.json(),
|
|
1855
|
-
),
|
|
1856
|
-
)
|
|
1857
|
-
if _response.status_code == 422:
|
|
1858
|
-
raise UnprocessableEntityError(
|
|
1859
|
-
typing.cast(
|
|
1860
|
-
HttpValidationError,
|
|
1861
|
-
construct_type(
|
|
1862
|
-
type_=HttpValidationError, # type: ignore
|
|
1863
|
-
object_=_response.json(),
|
|
1864
|
-
),
|
|
1865
|
-
)
|
|
1866
|
-
)
|
|
1867
|
-
_response_json = _response.json()
|
|
1868
|
-
except JSONDecodeError:
|
|
1869
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1870
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1871
|
-
|
|
1872
|
-
async def delete_file_from_folder(
|
|
1873
|
-
self, folder_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
1874
|
-
) -> None:
|
|
1875
|
-
"""
|
|
1876
|
-
Delete a file from a folder.
|
|
1877
|
-
|
|
1878
|
-
Parameters
|
|
1879
|
-
----------
|
|
1880
|
-
folder_id : str
|
|
1881
|
-
|
|
1882
|
-
file_id : str
|
|
1883
|
-
|
|
1884
|
-
request_options : typing.Optional[RequestOptions]
|
|
1885
|
-
Request-specific configuration.
|
|
1886
|
-
|
|
1887
|
-
Returns
|
|
1888
|
-
-------
|
|
1889
|
-
None
|
|
1890
|
-
|
|
1891
|
-
Examples
|
|
1892
|
-
--------
|
|
1893
|
-
import asyncio
|
|
1894
|
-
|
|
1895
|
-
from letta_client import AsyncLetta
|
|
1896
|
-
|
|
1897
|
-
client = AsyncLetta(
|
|
1898
|
-
project="YOUR_PROJECT",
|
|
1899
|
-
token="YOUR_TOKEN",
|
|
1900
|
-
)
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
async def main() -> None:
|
|
1904
|
-
await client.folders.delete_file_from_folder(
|
|
1905
|
-
folder_id="folder_id",
|
|
1906
|
-
file_id="file_id",
|
|
1907
|
-
)
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
asyncio.run(main())
|
|
1911
|
-
"""
|
|
1912
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
1913
|
-
f"v1/folders/{jsonable_encoder(folder_id)}/{jsonable_encoder(file_id)}",
|
|
1914
|
-
method="DELETE",
|
|
1915
|
-
request_options=request_options,
|
|
1916
|
-
)
|
|
1917
|
-
try:
|
|
1918
|
-
if 200 <= _response.status_code < 300:
|
|
1919
|
-
return
|
|
1920
|
-
if _response.status_code == 422:
|
|
1921
|
-
raise UnprocessableEntityError(
|
|
1922
|
-
typing.cast(
|
|
1923
|
-
HttpValidationError,
|
|
1924
|
-
construct_type(
|
|
1925
|
-
type_=HttpValidationError, # type: ignore
|
|
1926
|
-
object_=_response.json(),
|
|
1927
|
-
),
|
|
1928
|
-
)
|
|
1929
|
-
)
|
|
1930
|
-
_response_json = _response.json()
|
|
1931
|
-
except JSONDecodeError:
|
|
1932
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1933
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|