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.

@@ -0,0 +1,412 @@
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.agent_state import AgentState
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 ...types.source import Source
14
+ from ...core.client_wrapper import AsyncClientWrapper
15
+
16
+
17
+ class FoldersClient:
18
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
19
+ self._client_wrapper = client_wrapper
20
+
21
+ def attach(
22
+ self, agent_id: str, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
23
+ ) -> AgentState:
24
+ """
25
+ Attach a folder to an agent.
26
+
27
+ Parameters
28
+ ----------
29
+ agent_id : str
30
+
31
+ folder_id : str
32
+
33
+ request_options : typing.Optional[RequestOptions]
34
+ Request-specific configuration.
35
+
36
+ Returns
37
+ -------
38
+ AgentState
39
+ Successful Response
40
+
41
+ Examples
42
+ --------
43
+ from letta_client import Letta
44
+
45
+ client = Letta(
46
+ project="YOUR_PROJECT",
47
+ token="YOUR_TOKEN",
48
+ )
49
+ client.agents.folders.attach(
50
+ agent_id="agent_id",
51
+ folder_id="folder_id",
52
+ )
53
+ """
54
+ _response = self._client_wrapper.httpx_client.request(
55
+ f"v1/agents/{jsonable_encoder(agent_id)}/folders/attach/{jsonable_encoder(folder_id)}",
56
+ method="PATCH",
57
+ request_options=request_options,
58
+ )
59
+ try:
60
+ if 200 <= _response.status_code < 300:
61
+ return typing.cast(
62
+ AgentState,
63
+ construct_type(
64
+ type_=AgentState, # type: ignore
65
+ object_=_response.json(),
66
+ ),
67
+ )
68
+ if _response.status_code == 422:
69
+ raise UnprocessableEntityError(
70
+ typing.cast(
71
+ HttpValidationError,
72
+ construct_type(
73
+ type_=HttpValidationError, # type: ignore
74
+ object_=_response.json(),
75
+ ),
76
+ )
77
+ )
78
+ _response_json = _response.json()
79
+ except JSONDecodeError:
80
+ raise ApiError(status_code=_response.status_code, body=_response.text)
81
+ raise ApiError(status_code=_response.status_code, body=_response_json)
82
+
83
+ def detach(
84
+ self, agent_id: str, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
85
+ ) -> AgentState:
86
+ """
87
+ Detach a folder from an agent.
88
+
89
+ Parameters
90
+ ----------
91
+ agent_id : str
92
+
93
+ folder_id : str
94
+
95
+ request_options : typing.Optional[RequestOptions]
96
+ Request-specific configuration.
97
+
98
+ Returns
99
+ -------
100
+ AgentState
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.folders.detach(
112
+ agent_id="agent_id",
113
+ folder_id="folder_id",
114
+ )
115
+ """
116
+ _response = self._client_wrapper.httpx_client.request(
117
+ f"v1/agents/{jsonable_encoder(agent_id)}/folders/detach/{jsonable_encoder(folder_id)}",
118
+ method="PATCH",
119
+ request_options=request_options,
120
+ )
121
+ try:
122
+ if 200 <= _response.status_code < 300:
123
+ return typing.cast(
124
+ AgentState,
125
+ construct_type(
126
+ type_=AgentState, # 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 list(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Source]:
146
+ """
147
+ Get the folders associated with an agent.
148
+
149
+ Parameters
150
+ ----------
151
+ agent_id : str
152
+
153
+ request_options : typing.Optional[RequestOptions]
154
+ Request-specific configuration.
155
+
156
+ Returns
157
+ -------
158
+ typing.List[Source]
159
+ Successful Response
160
+
161
+ Examples
162
+ --------
163
+ from letta_client import Letta
164
+
165
+ client = Letta(
166
+ project="YOUR_PROJECT",
167
+ token="YOUR_TOKEN",
168
+ )
169
+ client.agents.folders.list(
170
+ agent_id="agent_id",
171
+ )
172
+ """
173
+ _response = self._client_wrapper.httpx_client.request(
174
+ f"v1/agents/{jsonable_encoder(agent_id)}/folders",
175
+ method="GET",
176
+ request_options=request_options,
177
+ )
178
+ try:
179
+ if 200 <= _response.status_code < 300:
180
+ return typing.cast(
181
+ typing.List[Source],
182
+ construct_type(
183
+ type_=typing.List[Source], # type: ignore
184
+ object_=_response.json(),
185
+ ),
186
+ )
187
+ if _response.status_code == 422:
188
+ raise UnprocessableEntityError(
189
+ typing.cast(
190
+ HttpValidationError,
191
+ construct_type(
192
+ type_=HttpValidationError, # type: ignore
193
+ object_=_response.json(),
194
+ ),
195
+ )
196
+ )
197
+ _response_json = _response.json()
198
+ except JSONDecodeError:
199
+ raise ApiError(status_code=_response.status_code, body=_response.text)
200
+ raise ApiError(status_code=_response.status_code, body=_response_json)
201
+
202
+
203
+ class AsyncFoldersClient:
204
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
205
+ self._client_wrapper = client_wrapper
206
+
207
+ async def attach(
208
+ self, agent_id: str, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
209
+ ) -> AgentState:
210
+ """
211
+ Attach a folder to an agent.
212
+
213
+ Parameters
214
+ ----------
215
+ agent_id : str
216
+
217
+ folder_id : str
218
+
219
+ request_options : typing.Optional[RequestOptions]
220
+ Request-specific configuration.
221
+
222
+ Returns
223
+ -------
224
+ AgentState
225
+ Successful Response
226
+
227
+ Examples
228
+ --------
229
+ import asyncio
230
+
231
+ from letta_client import AsyncLetta
232
+
233
+ client = AsyncLetta(
234
+ project="YOUR_PROJECT",
235
+ token="YOUR_TOKEN",
236
+ )
237
+
238
+
239
+ async def main() -> None:
240
+ await client.agents.folders.attach(
241
+ agent_id="agent_id",
242
+ folder_id="folder_id",
243
+ )
244
+
245
+
246
+ asyncio.run(main())
247
+ """
248
+ _response = await self._client_wrapper.httpx_client.request(
249
+ f"v1/agents/{jsonable_encoder(agent_id)}/folders/attach/{jsonable_encoder(folder_id)}",
250
+ method="PATCH",
251
+ request_options=request_options,
252
+ )
253
+ try:
254
+ if 200 <= _response.status_code < 300:
255
+ return typing.cast(
256
+ AgentState,
257
+ construct_type(
258
+ type_=AgentState, # type: ignore
259
+ object_=_response.json(),
260
+ ),
261
+ )
262
+ if _response.status_code == 422:
263
+ raise UnprocessableEntityError(
264
+ typing.cast(
265
+ HttpValidationError,
266
+ construct_type(
267
+ type_=HttpValidationError, # type: ignore
268
+ object_=_response.json(),
269
+ ),
270
+ )
271
+ )
272
+ _response_json = _response.json()
273
+ except JSONDecodeError:
274
+ raise ApiError(status_code=_response.status_code, body=_response.text)
275
+ raise ApiError(status_code=_response.status_code, body=_response_json)
276
+
277
+ async def detach(
278
+ self, agent_id: str, folder_id: str, *, request_options: typing.Optional[RequestOptions] = None
279
+ ) -> AgentState:
280
+ """
281
+ Detach a folder from an agent.
282
+
283
+ Parameters
284
+ ----------
285
+ agent_id : str
286
+
287
+ folder_id : str
288
+
289
+ request_options : typing.Optional[RequestOptions]
290
+ Request-specific configuration.
291
+
292
+ Returns
293
+ -------
294
+ AgentState
295
+ Successful Response
296
+
297
+ Examples
298
+ --------
299
+ import asyncio
300
+
301
+ from letta_client import AsyncLetta
302
+
303
+ client = AsyncLetta(
304
+ project="YOUR_PROJECT",
305
+ token="YOUR_TOKEN",
306
+ )
307
+
308
+
309
+ async def main() -> None:
310
+ await client.agents.folders.detach(
311
+ agent_id="agent_id",
312
+ folder_id="folder_id",
313
+ )
314
+
315
+
316
+ asyncio.run(main())
317
+ """
318
+ _response = await self._client_wrapper.httpx_client.request(
319
+ f"v1/agents/{jsonable_encoder(agent_id)}/folders/detach/{jsonable_encoder(folder_id)}",
320
+ method="PATCH",
321
+ request_options=request_options,
322
+ )
323
+ try:
324
+ if 200 <= _response.status_code < 300:
325
+ return typing.cast(
326
+ AgentState,
327
+ construct_type(
328
+ type_=AgentState, # type: ignore
329
+ object_=_response.json(),
330
+ ),
331
+ )
332
+ if _response.status_code == 422:
333
+ raise UnprocessableEntityError(
334
+ typing.cast(
335
+ HttpValidationError,
336
+ construct_type(
337
+ type_=HttpValidationError, # type: ignore
338
+ object_=_response.json(),
339
+ ),
340
+ )
341
+ )
342
+ _response_json = _response.json()
343
+ except JSONDecodeError:
344
+ raise ApiError(status_code=_response.status_code, body=_response.text)
345
+ raise ApiError(status_code=_response.status_code, body=_response_json)
346
+
347
+ async def list(
348
+ self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
349
+ ) -> typing.List[Source]:
350
+ """
351
+ Get the folders associated with an agent.
352
+
353
+ Parameters
354
+ ----------
355
+ agent_id : str
356
+
357
+ request_options : typing.Optional[RequestOptions]
358
+ Request-specific configuration.
359
+
360
+ Returns
361
+ -------
362
+ typing.List[Source]
363
+ Successful Response
364
+
365
+ Examples
366
+ --------
367
+ import asyncio
368
+
369
+ from letta_client import AsyncLetta
370
+
371
+ client = AsyncLetta(
372
+ project="YOUR_PROJECT",
373
+ token="YOUR_TOKEN",
374
+ )
375
+
376
+
377
+ async def main() -> None:
378
+ await client.agents.folders.list(
379
+ agent_id="agent_id",
380
+ )
381
+
382
+
383
+ asyncio.run(main())
384
+ """
385
+ _response = await self._client_wrapper.httpx_client.request(
386
+ f"v1/agents/{jsonable_encoder(agent_id)}/folders",
387
+ method="GET",
388
+ request_options=request_options,
389
+ )
390
+ try:
391
+ if 200 <= _response.status_code < 300:
392
+ return typing.cast(
393
+ typing.List[Source],
394
+ construct_type(
395
+ type_=typing.List[Source], # type: ignore
396
+ object_=_response.json(),
397
+ ),
398
+ )
399
+ if _response.status_code == 422:
400
+ raise UnprocessableEntityError(
401
+ typing.cast(
402
+ HttpValidationError,
403
+ construct_type(
404
+ type_=HttpValidationError, # type: ignore
405
+ object_=_response.json(),
406
+ ),
407
+ )
408
+ )
409
+ _response_json = _response.json()
410
+ except JSONDecodeError:
411
+ raise ApiError(status_code=_response.status_code, body=_response.text)
412
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -24,7 +24,7 @@ class BaseClientWrapper:
24
24
  headers: typing.Dict[str, str] = {
25
25
  "X-Fern-Language": "Python",
26
26
  "X-Fern-SDK-Name": "letta-client",
27
- "X-Fern-SDK-Version": "0.1.217",
27
+ "X-Fern-SDK-Version": "0.1.218",
28
28
  }
29
29
  if self._project is not None:
30
30
  headers["X-Project"] = self._project
@@ -1,2 +1,5 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ from . import files, passages
4
+
5
+ __all__ = ["files", "passages"]