letta-client 0.1.121__py3-none-any.whl → 0.1.122__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 +7 -6
- letta_client/agents/__init__.py +2 -1
- letta_client/agents/client.py +90 -581
- letta_client/agents/groups/client.py +167 -0
- letta_client/agents/messages/client.py +145 -0
- letta_client/agents/passages/client.py +289 -0
- letta_client/base_client.py +12 -0
- letta_client/batches/__init__.py +2 -0
- letta_client/{messages/batches → batches}/client.py +19 -19
- letta_client/blocks/__init__.py +3 -0
- letta_client/blocks/agents/__init__.py +2 -0
- letta_client/blocks/agents/client.py +149 -0
- letta_client/blocks/client.py +4 -127
- letta_client/core/client_wrapper.py +1 -1
- letta_client/embeddings/__init__.py +2 -0
- letta_client/embeddings/client.py +108 -0
- letta_client/groups/client.py +0 -124
- letta_client/groups/messages/client.py +124 -0
- letta_client/identities/__init__.py +3 -0
- letta_client/identities/client.py +4 -154
- letta_client/identities/properties/__init__.py +2 -0
- letta_client/identities/properties/client.py +181 -0
- letta_client/messages/__init__.py +0 -3
- letta_client/messages/client.py +0 -4
- letta_client/models/client.py +4 -97
- letta_client/providers/client.py +173 -10
- letta_client/runs/__init__.py +3 -0
- letta_client/runs/client.py +34 -480
- letta_client/runs/messages/__init__.py +2 -0
- letta_client/runs/messages/client.py +234 -0
- letta_client/runs/steps/__init__.py +2 -0
- letta_client/runs/steps/client.py +217 -0
- letta_client/runs/usage/__init__.py +2 -0
- letta_client/runs/usage/client.py +145 -0
- letta_client/sources/client.py +6 -4
- letta_client/steps/client.py +78 -4
- letta_client/tags/__init__.py +2 -0
- letta_client/tags/client.py +92 -0
- letta_client/templates/__init__.py +5 -6
- letta_client/templates/agents/__init__.py +5 -0
- letta_client/templates/agents/client.py +208 -0
- letta_client/templates/agents/types/__init__.py +5 -0
- letta_client/templates/{types/templates_create_agents_response.py → agents/types/agents_create_response.py} +4 -4
- letta_client/templates/client.py +6 -191
- letta_client/templates/types/__init__.py +1 -6
- letta_client/tools/client.py +4 -4
- {letta_client-0.1.121.dist-info → letta_client-0.1.122.dist-info}/METADATA +1 -1
- {letta_client-0.1.121.dist-info → letta_client-0.1.122.dist-info}/RECORD +50 -31
- /letta_client/{messages/batches → agents/groups}/__init__.py +0 -0
- {letta_client-0.1.121.dist-info → letta_client-0.1.122.dist-info}/WHEEL +0 -0
letta_client/runs/client.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
from ..core.client_wrapper import SyncClientWrapper
|
|
4
|
+
from .messages.client import MessagesClient
|
|
5
|
+
from .usage.client import UsageClient
|
|
6
|
+
from .steps.client import StepsClient
|
|
4
7
|
import typing
|
|
5
8
|
from ..core.request_options import RequestOptions
|
|
6
9
|
from ..types.run import Run
|
|
@@ -10,16 +13,18 @@ from ..types.http_validation_error import HttpValidationError
|
|
|
10
13
|
from json.decoder import JSONDecodeError
|
|
11
14
|
from ..core.api_error import ApiError
|
|
12
15
|
from ..core.jsonable_encoder import jsonable_encoder
|
|
13
|
-
from ..types.message_role import MessageRole
|
|
14
|
-
from ..types.letta_message_union import LettaMessageUnion
|
|
15
|
-
from ..types.usage_statistics import UsageStatistics
|
|
16
|
-
from ..types.step import Step
|
|
17
16
|
from ..core.client_wrapper import AsyncClientWrapper
|
|
17
|
+
from .messages.client import AsyncMessagesClient
|
|
18
|
+
from .usage.client import AsyncUsageClient
|
|
19
|
+
from .steps.client import AsyncStepsClient
|
|
18
20
|
|
|
19
21
|
|
|
20
22
|
class RunsClient:
|
|
21
23
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
22
24
|
self._client_wrapper = client_wrapper
|
|
25
|
+
self.messages = MessagesClient(client_wrapper=self._client_wrapper)
|
|
26
|
+
self.usage = UsageClient(client_wrapper=self._client_wrapper)
|
|
27
|
+
self.steps = StepsClient(client_wrapper=self._client_wrapper)
|
|
23
28
|
|
|
24
29
|
def list_runs(
|
|
25
30
|
self,
|
|
@@ -84,7 +89,7 @@ class RunsClient:
|
|
|
84
89
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
85
90
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
86
91
|
|
|
87
|
-
def
|
|
92
|
+
def list_active(
|
|
88
93
|
self,
|
|
89
94
|
*,
|
|
90
95
|
agent_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
@@ -113,7 +118,7 @@ class RunsClient:
|
|
|
113
118
|
client = Letta(
|
|
114
119
|
token="YOUR_TOKEN",
|
|
115
120
|
)
|
|
116
|
-
client.runs.
|
|
121
|
+
client.runs.list_active()
|
|
117
122
|
"""
|
|
118
123
|
_response = self._client_wrapper.httpx_client.request(
|
|
119
124
|
"v1/runs/active",
|
|
@@ -147,7 +152,7 @@ class RunsClient:
|
|
|
147
152
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
148
153
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
149
154
|
|
|
150
|
-
def
|
|
155
|
+
def retrieve(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
151
156
|
"""
|
|
152
157
|
Get the status of a run.
|
|
153
158
|
|
|
@@ -170,7 +175,7 @@ class RunsClient:
|
|
|
170
175
|
client = Letta(
|
|
171
176
|
token="YOUR_TOKEN",
|
|
172
177
|
)
|
|
173
|
-
client.runs.
|
|
178
|
+
client.runs.retrieve(
|
|
174
179
|
run_id="run_id",
|
|
175
180
|
)
|
|
176
181
|
"""
|
|
@@ -203,7 +208,7 @@ class RunsClient:
|
|
|
203
208
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
204
209
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
205
210
|
|
|
206
|
-
def
|
|
211
|
+
def delete(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
207
212
|
"""
|
|
208
213
|
Delete a run by its run_id.
|
|
209
214
|
|
|
@@ -226,7 +231,7 @@ class RunsClient:
|
|
|
226
231
|
client = Letta(
|
|
227
232
|
token="YOUR_TOKEN",
|
|
228
233
|
)
|
|
229
|
-
client.runs.
|
|
234
|
+
client.runs.delete(
|
|
230
235
|
run_id="run_id",
|
|
231
236
|
)
|
|
232
237
|
"""
|
|
@@ -259,211 +264,16 @@ class RunsClient:
|
|
|
259
264
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
260
265
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
261
266
|
|
|
262
|
-
def
|
|
263
|
-
self,
|
|
264
|
-
run_id: str,
|
|
265
|
-
*,
|
|
266
|
-
before: typing.Optional[str] = None,
|
|
267
|
-
after: typing.Optional[str] = None,
|
|
268
|
-
limit: typing.Optional[int] = None,
|
|
269
|
-
order: typing.Optional[str] = None,
|
|
270
|
-
role: typing.Optional[MessageRole] = None,
|
|
271
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
272
|
-
) -> typing.List[LettaMessageUnion]:
|
|
273
|
-
"""
|
|
274
|
-
Get messages associated with a run with filtering options.
|
|
275
|
-
|
|
276
|
-
Args:
|
|
277
|
-
run_id: ID of the run
|
|
278
|
-
before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
|
|
279
|
-
after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
|
|
280
|
-
limit: Maximum number of messages to return
|
|
281
|
-
order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
282
|
-
role: Filter by role (user/assistant/system/tool)
|
|
283
|
-
return_message_object: Whether to return Message objects or LettaMessage objects
|
|
284
|
-
user_id: ID of the user making the request
|
|
285
|
-
|
|
286
|
-
Returns:
|
|
287
|
-
A list of messages associated with the run. Default is List[LettaMessage].
|
|
288
|
-
|
|
289
|
-
Parameters
|
|
290
|
-
----------
|
|
291
|
-
run_id : str
|
|
292
|
-
|
|
293
|
-
before : typing.Optional[str]
|
|
294
|
-
Cursor for pagination
|
|
295
|
-
|
|
296
|
-
after : typing.Optional[str]
|
|
297
|
-
Cursor for pagination
|
|
298
|
-
|
|
299
|
-
limit : typing.Optional[int]
|
|
300
|
-
Maximum number of messages to return
|
|
301
|
-
|
|
302
|
-
order : typing.Optional[str]
|
|
303
|
-
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
304
|
-
|
|
305
|
-
role : typing.Optional[MessageRole]
|
|
306
|
-
Filter by role
|
|
307
|
-
|
|
308
|
-
request_options : typing.Optional[RequestOptions]
|
|
309
|
-
Request-specific configuration.
|
|
310
|
-
|
|
311
|
-
Returns
|
|
312
|
-
-------
|
|
313
|
-
typing.List[LettaMessageUnion]
|
|
314
|
-
Successful Response
|
|
315
|
-
|
|
316
|
-
Examples
|
|
317
|
-
--------
|
|
318
|
-
from letta_client import Letta
|
|
319
|
-
|
|
320
|
-
client = Letta(
|
|
321
|
-
token="YOUR_TOKEN",
|
|
322
|
-
)
|
|
323
|
-
client.runs.list_run_messages(
|
|
324
|
-
run_id="run_id",
|
|
325
|
-
)
|
|
326
|
-
"""
|
|
327
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
328
|
-
f"v1/runs/{jsonable_encoder(run_id)}/messages",
|
|
329
|
-
method="GET",
|
|
330
|
-
params={
|
|
331
|
-
"before": before,
|
|
332
|
-
"after": after,
|
|
333
|
-
"limit": limit,
|
|
334
|
-
"order": order,
|
|
335
|
-
"role": role,
|
|
336
|
-
},
|
|
337
|
-
request_options=request_options,
|
|
338
|
-
)
|
|
339
|
-
try:
|
|
340
|
-
if 200 <= _response.status_code < 300:
|
|
341
|
-
return typing.cast(
|
|
342
|
-
typing.List[LettaMessageUnion],
|
|
343
|
-
construct_type(
|
|
344
|
-
type_=typing.List[LettaMessageUnion], # type: ignore
|
|
345
|
-
object_=_response.json(),
|
|
346
|
-
),
|
|
347
|
-
)
|
|
348
|
-
if _response.status_code == 422:
|
|
349
|
-
raise UnprocessableEntityError(
|
|
350
|
-
typing.cast(
|
|
351
|
-
HttpValidationError,
|
|
352
|
-
construct_type(
|
|
353
|
-
type_=HttpValidationError, # type: ignore
|
|
354
|
-
object_=_response.json(),
|
|
355
|
-
),
|
|
356
|
-
)
|
|
357
|
-
)
|
|
358
|
-
_response_json = _response.json()
|
|
359
|
-
except JSONDecodeError:
|
|
360
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
361
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
362
|
-
|
|
363
|
-
def retrieve_run_usage(
|
|
364
|
-
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
365
|
-
) -> UsageStatistics:
|
|
366
|
-
"""
|
|
367
|
-
Get usage statistics for a run.
|
|
368
|
-
|
|
369
|
-
Parameters
|
|
370
|
-
----------
|
|
371
|
-
run_id : str
|
|
372
|
-
|
|
373
|
-
request_options : typing.Optional[RequestOptions]
|
|
374
|
-
Request-specific configuration.
|
|
375
|
-
|
|
376
|
-
Returns
|
|
377
|
-
-------
|
|
378
|
-
UsageStatistics
|
|
379
|
-
Successful Response
|
|
380
|
-
|
|
381
|
-
Examples
|
|
382
|
-
--------
|
|
383
|
-
from letta_client import Letta
|
|
384
|
-
|
|
385
|
-
client = Letta(
|
|
386
|
-
token="YOUR_TOKEN",
|
|
387
|
-
)
|
|
388
|
-
client.runs.retrieve_run_usage(
|
|
389
|
-
run_id="run_id",
|
|
390
|
-
)
|
|
391
|
-
"""
|
|
392
|
-
_response = self._client_wrapper.httpx_client.request(
|
|
393
|
-
f"v1/runs/{jsonable_encoder(run_id)}/usage",
|
|
394
|
-
method="GET",
|
|
395
|
-
request_options=request_options,
|
|
396
|
-
)
|
|
397
|
-
try:
|
|
398
|
-
if 200 <= _response.status_code < 300:
|
|
399
|
-
return typing.cast(
|
|
400
|
-
UsageStatistics,
|
|
401
|
-
construct_type(
|
|
402
|
-
type_=UsageStatistics, # type: ignore
|
|
403
|
-
object_=_response.json(),
|
|
404
|
-
),
|
|
405
|
-
)
|
|
406
|
-
if _response.status_code == 422:
|
|
407
|
-
raise UnprocessableEntityError(
|
|
408
|
-
typing.cast(
|
|
409
|
-
HttpValidationError,
|
|
410
|
-
construct_type(
|
|
411
|
-
type_=HttpValidationError, # type: ignore
|
|
412
|
-
object_=_response.json(),
|
|
413
|
-
),
|
|
414
|
-
)
|
|
415
|
-
)
|
|
416
|
-
_response_json = _response.json()
|
|
417
|
-
except JSONDecodeError:
|
|
418
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
419
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
420
|
-
|
|
421
|
-
def list_run_steps(
|
|
422
|
-
self,
|
|
423
|
-
run_id: str,
|
|
424
|
-
*,
|
|
425
|
-
before: typing.Optional[str] = None,
|
|
426
|
-
after: typing.Optional[str] = None,
|
|
427
|
-
limit: typing.Optional[int] = None,
|
|
428
|
-
order: typing.Optional[str] = None,
|
|
429
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
430
|
-
) -> typing.List[Step]:
|
|
267
|
+
def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
431
268
|
"""
|
|
432
|
-
Get messages associated with a run with filtering options.
|
|
433
|
-
|
|
434
|
-
Args:
|
|
435
|
-
run_id: ID of the run
|
|
436
|
-
before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
|
|
437
|
-
after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
|
|
438
|
-
limit: Maximum number of steps to return
|
|
439
|
-
order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
440
|
-
|
|
441
|
-
Returns:
|
|
442
|
-
A list of steps associated with the run.
|
|
443
|
-
|
|
444
269
|
Parameters
|
|
445
270
|
----------
|
|
446
|
-
run_id : str
|
|
447
|
-
|
|
448
|
-
before : typing.Optional[str]
|
|
449
|
-
Cursor for pagination
|
|
450
|
-
|
|
451
|
-
after : typing.Optional[str]
|
|
452
|
-
Cursor for pagination
|
|
453
|
-
|
|
454
|
-
limit : typing.Optional[int]
|
|
455
|
-
Maximum number of messages to return
|
|
456
|
-
|
|
457
|
-
order : typing.Optional[str]
|
|
458
|
-
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
459
|
-
|
|
460
271
|
request_options : typing.Optional[RequestOptions]
|
|
461
272
|
Request-specific configuration.
|
|
462
273
|
|
|
463
274
|
Returns
|
|
464
275
|
-------
|
|
465
|
-
|
|
466
|
-
Successful Response
|
|
276
|
+
None
|
|
467
277
|
|
|
468
278
|
Examples
|
|
469
279
|
--------
|
|
@@ -472,40 +282,16 @@ class RunsClient:
|
|
|
472
282
|
client = Letta(
|
|
473
283
|
token="YOUR_TOKEN",
|
|
474
284
|
)
|
|
475
|
-
client.runs.
|
|
476
|
-
run_id="run_id",
|
|
477
|
-
)
|
|
285
|
+
client.runs.list()
|
|
478
286
|
"""
|
|
479
287
|
_response = self._client_wrapper.httpx_client.request(
|
|
480
|
-
|
|
288
|
+
"v1/runs",
|
|
481
289
|
method="GET",
|
|
482
|
-
params={
|
|
483
|
-
"before": before,
|
|
484
|
-
"after": after,
|
|
485
|
-
"limit": limit,
|
|
486
|
-
"order": order,
|
|
487
|
-
},
|
|
488
290
|
request_options=request_options,
|
|
489
291
|
)
|
|
490
292
|
try:
|
|
491
293
|
if 200 <= _response.status_code < 300:
|
|
492
|
-
return
|
|
493
|
-
typing.List[Step],
|
|
494
|
-
construct_type(
|
|
495
|
-
type_=typing.List[Step], # type: ignore
|
|
496
|
-
object_=_response.json(),
|
|
497
|
-
),
|
|
498
|
-
)
|
|
499
|
-
if _response.status_code == 422:
|
|
500
|
-
raise UnprocessableEntityError(
|
|
501
|
-
typing.cast(
|
|
502
|
-
HttpValidationError,
|
|
503
|
-
construct_type(
|
|
504
|
-
type_=HttpValidationError, # type: ignore
|
|
505
|
-
object_=_response.json(),
|
|
506
|
-
),
|
|
507
|
-
)
|
|
508
|
-
)
|
|
294
|
+
return
|
|
509
295
|
_response_json = _response.json()
|
|
510
296
|
except JSONDecodeError:
|
|
511
297
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -515,6 +301,9 @@ class RunsClient:
|
|
|
515
301
|
class AsyncRunsClient:
|
|
516
302
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
517
303
|
self._client_wrapper = client_wrapper
|
|
304
|
+
self.messages = AsyncMessagesClient(client_wrapper=self._client_wrapper)
|
|
305
|
+
self.usage = AsyncUsageClient(client_wrapper=self._client_wrapper)
|
|
306
|
+
self.steps = AsyncStepsClient(client_wrapper=self._client_wrapper)
|
|
518
307
|
|
|
519
308
|
async def list_runs(
|
|
520
309
|
self,
|
|
@@ -587,7 +376,7 @@ class AsyncRunsClient:
|
|
|
587
376
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
588
377
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
589
378
|
|
|
590
|
-
async def
|
|
379
|
+
async def list_active(
|
|
591
380
|
self,
|
|
592
381
|
*,
|
|
593
382
|
agent_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
@@ -621,7 +410,7 @@ class AsyncRunsClient:
|
|
|
621
410
|
|
|
622
411
|
|
|
623
412
|
async def main() -> None:
|
|
624
|
-
await client.runs.
|
|
413
|
+
await client.runs.list_active()
|
|
625
414
|
|
|
626
415
|
|
|
627
416
|
asyncio.run(main())
|
|
@@ -658,7 +447,7 @@ class AsyncRunsClient:
|
|
|
658
447
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
659
448
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
660
449
|
|
|
661
|
-
async def
|
|
450
|
+
async def retrieve(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
662
451
|
"""
|
|
663
452
|
Get the status of a run.
|
|
664
453
|
|
|
@@ -686,7 +475,7 @@ class AsyncRunsClient:
|
|
|
686
475
|
|
|
687
476
|
|
|
688
477
|
async def main() -> None:
|
|
689
|
-
await client.runs.
|
|
478
|
+
await client.runs.retrieve(
|
|
690
479
|
run_id="run_id",
|
|
691
480
|
)
|
|
692
481
|
|
|
@@ -722,7 +511,7 @@ class AsyncRunsClient:
|
|
|
722
511
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
723
512
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
724
513
|
|
|
725
|
-
async def
|
|
514
|
+
async def delete(self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Run:
|
|
726
515
|
"""
|
|
727
516
|
Delete a run by its run_id.
|
|
728
517
|
|
|
@@ -750,7 +539,7 @@ class AsyncRunsClient:
|
|
|
750
539
|
|
|
751
540
|
|
|
752
541
|
async def main() -> None:
|
|
753
|
-
await client.runs.
|
|
542
|
+
await client.runs.delete(
|
|
754
543
|
run_id="run_id",
|
|
755
544
|
)
|
|
756
545
|
|
|
@@ -786,227 +575,16 @@ class AsyncRunsClient:
|
|
|
786
575
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
787
576
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
788
577
|
|
|
789
|
-
async def
|
|
790
|
-
self,
|
|
791
|
-
run_id: str,
|
|
792
|
-
*,
|
|
793
|
-
before: typing.Optional[str] = None,
|
|
794
|
-
after: typing.Optional[str] = None,
|
|
795
|
-
limit: typing.Optional[int] = None,
|
|
796
|
-
order: typing.Optional[str] = None,
|
|
797
|
-
role: typing.Optional[MessageRole] = None,
|
|
798
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
799
|
-
) -> typing.List[LettaMessageUnion]:
|
|
800
|
-
"""
|
|
801
|
-
Get messages associated with a run with filtering options.
|
|
802
|
-
|
|
803
|
-
Args:
|
|
804
|
-
run_id: ID of the run
|
|
805
|
-
before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
|
|
806
|
-
after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
|
|
807
|
-
limit: Maximum number of messages to return
|
|
808
|
-
order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
809
|
-
role: Filter by role (user/assistant/system/tool)
|
|
810
|
-
return_message_object: Whether to return Message objects or LettaMessage objects
|
|
811
|
-
user_id: ID of the user making the request
|
|
812
|
-
|
|
813
|
-
Returns:
|
|
814
|
-
A list of messages associated with the run. Default is List[LettaMessage].
|
|
815
|
-
|
|
816
|
-
Parameters
|
|
817
|
-
----------
|
|
818
|
-
run_id : str
|
|
819
|
-
|
|
820
|
-
before : typing.Optional[str]
|
|
821
|
-
Cursor for pagination
|
|
822
|
-
|
|
823
|
-
after : typing.Optional[str]
|
|
824
|
-
Cursor for pagination
|
|
825
|
-
|
|
826
|
-
limit : typing.Optional[int]
|
|
827
|
-
Maximum number of messages to return
|
|
828
|
-
|
|
829
|
-
order : typing.Optional[str]
|
|
830
|
-
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
831
|
-
|
|
832
|
-
role : typing.Optional[MessageRole]
|
|
833
|
-
Filter by role
|
|
834
|
-
|
|
835
|
-
request_options : typing.Optional[RequestOptions]
|
|
836
|
-
Request-specific configuration.
|
|
837
|
-
|
|
838
|
-
Returns
|
|
839
|
-
-------
|
|
840
|
-
typing.List[LettaMessageUnion]
|
|
841
|
-
Successful Response
|
|
842
|
-
|
|
843
|
-
Examples
|
|
844
|
-
--------
|
|
845
|
-
import asyncio
|
|
846
|
-
|
|
847
|
-
from letta_client import AsyncLetta
|
|
848
|
-
|
|
849
|
-
client = AsyncLetta(
|
|
850
|
-
token="YOUR_TOKEN",
|
|
851
|
-
)
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
async def main() -> None:
|
|
855
|
-
await client.runs.list_run_messages(
|
|
856
|
-
run_id="run_id",
|
|
857
|
-
)
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
asyncio.run(main())
|
|
861
|
-
"""
|
|
862
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
863
|
-
f"v1/runs/{jsonable_encoder(run_id)}/messages",
|
|
864
|
-
method="GET",
|
|
865
|
-
params={
|
|
866
|
-
"before": before,
|
|
867
|
-
"after": after,
|
|
868
|
-
"limit": limit,
|
|
869
|
-
"order": order,
|
|
870
|
-
"role": role,
|
|
871
|
-
},
|
|
872
|
-
request_options=request_options,
|
|
873
|
-
)
|
|
874
|
-
try:
|
|
875
|
-
if 200 <= _response.status_code < 300:
|
|
876
|
-
return typing.cast(
|
|
877
|
-
typing.List[LettaMessageUnion],
|
|
878
|
-
construct_type(
|
|
879
|
-
type_=typing.List[LettaMessageUnion], # type: ignore
|
|
880
|
-
object_=_response.json(),
|
|
881
|
-
),
|
|
882
|
-
)
|
|
883
|
-
if _response.status_code == 422:
|
|
884
|
-
raise UnprocessableEntityError(
|
|
885
|
-
typing.cast(
|
|
886
|
-
HttpValidationError,
|
|
887
|
-
construct_type(
|
|
888
|
-
type_=HttpValidationError, # type: ignore
|
|
889
|
-
object_=_response.json(),
|
|
890
|
-
),
|
|
891
|
-
)
|
|
892
|
-
)
|
|
893
|
-
_response_json = _response.json()
|
|
894
|
-
except JSONDecodeError:
|
|
895
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
896
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
897
|
-
|
|
898
|
-
async def retrieve_run_usage(
|
|
899
|
-
self, run_id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
900
|
-
) -> UsageStatistics:
|
|
901
|
-
"""
|
|
902
|
-
Get usage statistics for a run.
|
|
903
|
-
|
|
904
|
-
Parameters
|
|
905
|
-
----------
|
|
906
|
-
run_id : str
|
|
907
|
-
|
|
908
|
-
request_options : typing.Optional[RequestOptions]
|
|
909
|
-
Request-specific configuration.
|
|
910
|
-
|
|
911
|
-
Returns
|
|
912
|
-
-------
|
|
913
|
-
UsageStatistics
|
|
914
|
-
Successful Response
|
|
915
|
-
|
|
916
|
-
Examples
|
|
917
|
-
--------
|
|
918
|
-
import asyncio
|
|
919
|
-
|
|
920
|
-
from letta_client import AsyncLetta
|
|
921
|
-
|
|
922
|
-
client = AsyncLetta(
|
|
923
|
-
token="YOUR_TOKEN",
|
|
924
|
-
)
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
async def main() -> None:
|
|
928
|
-
await client.runs.retrieve_run_usage(
|
|
929
|
-
run_id="run_id",
|
|
930
|
-
)
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
asyncio.run(main())
|
|
934
|
-
"""
|
|
935
|
-
_response = await self._client_wrapper.httpx_client.request(
|
|
936
|
-
f"v1/runs/{jsonable_encoder(run_id)}/usage",
|
|
937
|
-
method="GET",
|
|
938
|
-
request_options=request_options,
|
|
939
|
-
)
|
|
940
|
-
try:
|
|
941
|
-
if 200 <= _response.status_code < 300:
|
|
942
|
-
return typing.cast(
|
|
943
|
-
UsageStatistics,
|
|
944
|
-
construct_type(
|
|
945
|
-
type_=UsageStatistics, # type: ignore
|
|
946
|
-
object_=_response.json(),
|
|
947
|
-
),
|
|
948
|
-
)
|
|
949
|
-
if _response.status_code == 422:
|
|
950
|
-
raise UnprocessableEntityError(
|
|
951
|
-
typing.cast(
|
|
952
|
-
HttpValidationError,
|
|
953
|
-
construct_type(
|
|
954
|
-
type_=HttpValidationError, # type: ignore
|
|
955
|
-
object_=_response.json(),
|
|
956
|
-
),
|
|
957
|
-
)
|
|
958
|
-
)
|
|
959
|
-
_response_json = _response.json()
|
|
960
|
-
except JSONDecodeError:
|
|
961
|
-
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
962
|
-
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
963
|
-
|
|
964
|
-
async def list_run_steps(
|
|
965
|
-
self,
|
|
966
|
-
run_id: str,
|
|
967
|
-
*,
|
|
968
|
-
before: typing.Optional[str] = None,
|
|
969
|
-
after: typing.Optional[str] = None,
|
|
970
|
-
limit: typing.Optional[int] = None,
|
|
971
|
-
order: typing.Optional[str] = None,
|
|
972
|
-
request_options: typing.Optional[RequestOptions] = None,
|
|
973
|
-
) -> typing.List[Step]:
|
|
578
|
+
async def list(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
974
579
|
"""
|
|
975
|
-
Get messages associated with a run with filtering options.
|
|
976
|
-
|
|
977
|
-
Args:
|
|
978
|
-
run_id: ID of the run
|
|
979
|
-
before: A cursor for use in pagination. `before` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.
|
|
980
|
-
after: A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.
|
|
981
|
-
limit: Maximum number of steps to return
|
|
982
|
-
order: Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
983
|
-
|
|
984
|
-
Returns:
|
|
985
|
-
A list of steps associated with the run.
|
|
986
|
-
|
|
987
580
|
Parameters
|
|
988
581
|
----------
|
|
989
|
-
run_id : str
|
|
990
|
-
|
|
991
|
-
before : typing.Optional[str]
|
|
992
|
-
Cursor for pagination
|
|
993
|
-
|
|
994
|
-
after : typing.Optional[str]
|
|
995
|
-
Cursor for pagination
|
|
996
|
-
|
|
997
|
-
limit : typing.Optional[int]
|
|
998
|
-
Maximum number of messages to return
|
|
999
|
-
|
|
1000
|
-
order : typing.Optional[str]
|
|
1001
|
-
Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.
|
|
1002
|
-
|
|
1003
582
|
request_options : typing.Optional[RequestOptions]
|
|
1004
583
|
Request-specific configuration.
|
|
1005
584
|
|
|
1006
585
|
Returns
|
|
1007
586
|
-------
|
|
1008
|
-
|
|
1009
|
-
Successful Response
|
|
587
|
+
None
|
|
1010
588
|
|
|
1011
589
|
Examples
|
|
1012
590
|
--------
|
|
@@ -1020,43 +598,19 @@ class AsyncRunsClient:
|
|
|
1020
598
|
|
|
1021
599
|
|
|
1022
600
|
async def main() -> None:
|
|
1023
|
-
await client.runs.
|
|
1024
|
-
run_id="run_id",
|
|
1025
|
-
)
|
|
601
|
+
await client.runs.list()
|
|
1026
602
|
|
|
1027
603
|
|
|
1028
604
|
asyncio.run(main())
|
|
1029
605
|
"""
|
|
1030
606
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1031
|
-
|
|
607
|
+
"v1/runs",
|
|
1032
608
|
method="GET",
|
|
1033
|
-
params={
|
|
1034
|
-
"before": before,
|
|
1035
|
-
"after": after,
|
|
1036
|
-
"limit": limit,
|
|
1037
|
-
"order": order,
|
|
1038
|
-
},
|
|
1039
609
|
request_options=request_options,
|
|
1040
610
|
)
|
|
1041
611
|
try:
|
|
1042
612
|
if 200 <= _response.status_code < 300:
|
|
1043
|
-
return
|
|
1044
|
-
typing.List[Step],
|
|
1045
|
-
construct_type(
|
|
1046
|
-
type_=typing.List[Step], # type: ignore
|
|
1047
|
-
object_=_response.json(),
|
|
1048
|
-
),
|
|
1049
|
-
)
|
|
1050
|
-
if _response.status_code == 422:
|
|
1051
|
-
raise UnprocessableEntityError(
|
|
1052
|
-
typing.cast(
|
|
1053
|
-
HttpValidationError,
|
|
1054
|
-
construct_type(
|
|
1055
|
-
type_=HttpValidationError, # type: ignore
|
|
1056
|
-
object_=_response.json(),
|
|
1057
|
-
),
|
|
1058
|
-
)
|
|
1059
|
-
)
|
|
613
|
+
return
|
|
1060
614
|
_response_json = _response.json()
|
|
1061
615
|
except JSONDecodeError:
|
|
1062
616
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|