letta-client 0.1.188__py3-none-any.whl → 0.1.189__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/client.py +146 -0
- letta_client/agents/messages/client.py +6 -0
- letta_client/client.py +23 -0
- letta_client/core/client_wrapper.py +1 -1
- letta_client/jobs/client.py +226 -4
- letta_client/types/stop_reason_type.py +2 -1
- letta_client/types/update_ssemcp_server.py +5 -0
- letta_client/types/update_streamable_httpmcp_server.py +5 -0
- {letta_client-0.1.188.dist-info → letta_client-0.1.189.dist-info}/METADATA +1 -1
- {letta_client-0.1.188.dist-info → letta_client-0.1.189.dist-info}/RECORD +11 -11
- {letta_client-0.1.188.dist-info → letta_client-0.1.189.dist-info}/WHEEL +0 -0
letta_client/agents/client.py
CHANGED
|
@@ -1061,6 +1061,75 @@ class AgentsClient:
|
|
|
1061
1061
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1062
1062
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1063
1063
|
|
|
1064
|
+
def cancel_agent_run(
|
|
1065
|
+
self,
|
|
1066
|
+
agent_id: str,
|
|
1067
|
+
*,
|
|
1068
|
+
request: typing.Optional[typing.Sequence[str]] = None,
|
|
1069
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1070
|
+
) -> typing.Dict[str, typing.Optional[typing.Any]]:
|
|
1071
|
+
"""
|
|
1072
|
+
Cancel runs associated with an agent. If run_ids are passed in, cancel those in particular.
|
|
1073
|
+
|
|
1074
|
+
Note to cancel active runs associated with an agent, redis is required.
|
|
1075
|
+
|
|
1076
|
+
Parameters
|
|
1077
|
+
----------
|
|
1078
|
+
agent_id : str
|
|
1079
|
+
|
|
1080
|
+
request : typing.Optional[typing.Sequence[str]]
|
|
1081
|
+
|
|
1082
|
+
request_options : typing.Optional[RequestOptions]
|
|
1083
|
+
Request-specific configuration.
|
|
1084
|
+
|
|
1085
|
+
Returns
|
|
1086
|
+
-------
|
|
1087
|
+
typing.Dict[str, typing.Optional[typing.Any]]
|
|
1088
|
+
Successful Response
|
|
1089
|
+
|
|
1090
|
+
Examples
|
|
1091
|
+
--------
|
|
1092
|
+
from letta_client import Letta
|
|
1093
|
+
|
|
1094
|
+
client = Letta(
|
|
1095
|
+
project="YOUR_PROJECT",
|
|
1096
|
+
token="YOUR_TOKEN",
|
|
1097
|
+
)
|
|
1098
|
+
client.agents.cancel_agent_run(
|
|
1099
|
+
agent_id="agent_id",
|
|
1100
|
+
)
|
|
1101
|
+
"""
|
|
1102
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
1103
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/messages/cancel",
|
|
1104
|
+
method="POST",
|
|
1105
|
+
json=request,
|
|
1106
|
+
request_options=request_options,
|
|
1107
|
+
omit=OMIT,
|
|
1108
|
+
)
|
|
1109
|
+
try:
|
|
1110
|
+
if 200 <= _response.status_code < 300:
|
|
1111
|
+
return typing.cast(
|
|
1112
|
+
typing.Dict[str, typing.Optional[typing.Any]],
|
|
1113
|
+
construct_type(
|
|
1114
|
+
type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
|
|
1115
|
+
object_=_response.json(),
|
|
1116
|
+
),
|
|
1117
|
+
)
|
|
1118
|
+
if _response.status_code == 422:
|
|
1119
|
+
raise UnprocessableEntityError(
|
|
1120
|
+
typing.cast(
|
|
1121
|
+
HttpValidationError,
|
|
1122
|
+
construct_type(
|
|
1123
|
+
type_=HttpValidationError, # type: ignore
|
|
1124
|
+
object_=_response.json(),
|
|
1125
|
+
),
|
|
1126
|
+
)
|
|
1127
|
+
)
|
|
1128
|
+
_response_json = _response.json()
|
|
1129
|
+
except JSONDecodeError:
|
|
1130
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
1131
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
1132
|
+
|
|
1064
1133
|
def summarize_agent_conversation(
|
|
1065
1134
|
self, agent_id: str, *, max_message_length: int, request_options: typing.Optional[RequestOptions] = None
|
|
1066
1135
|
) -> AgentState:
|
|
@@ -2298,6 +2367,83 @@ class AsyncAgentsClient:
|
|
|
2298
2367
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2299
2368
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2300
2369
|
|
|
2370
|
+
async def cancel_agent_run(
|
|
2371
|
+
self,
|
|
2372
|
+
agent_id: str,
|
|
2373
|
+
*,
|
|
2374
|
+
request: typing.Optional[typing.Sequence[str]] = None,
|
|
2375
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
2376
|
+
) -> typing.Dict[str, typing.Optional[typing.Any]]:
|
|
2377
|
+
"""
|
|
2378
|
+
Cancel runs associated with an agent. If run_ids are passed in, cancel those in particular.
|
|
2379
|
+
|
|
2380
|
+
Note to cancel active runs associated with an agent, redis is required.
|
|
2381
|
+
|
|
2382
|
+
Parameters
|
|
2383
|
+
----------
|
|
2384
|
+
agent_id : str
|
|
2385
|
+
|
|
2386
|
+
request : typing.Optional[typing.Sequence[str]]
|
|
2387
|
+
|
|
2388
|
+
request_options : typing.Optional[RequestOptions]
|
|
2389
|
+
Request-specific configuration.
|
|
2390
|
+
|
|
2391
|
+
Returns
|
|
2392
|
+
-------
|
|
2393
|
+
typing.Dict[str, typing.Optional[typing.Any]]
|
|
2394
|
+
Successful Response
|
|
2395
|
+
|
|
2396
|
+
Examples
|
|
2397
|
+
--------
|
|
2398
|
+
import asyncio
|
|
2399
|
+
|
|
2400
|
+
from letta_client import AsyncLetta
|
|
2401
|
+
|
|
2402
|
+
client = AsyncLetta(
|
|
2403
|
+
project="YOUR_PROJECT",
|
|
2404
|
+
token="YOUR_TOKEN",
|
|
2405
|
+
)
|
|
2406
|
+
|
|
2407
|
+
|
|
2408
|
+
async def main() -> None:
|
|
2409
|
+
await client.agents.cancel_agent_run(
|
|
2410
|
+
agent_id="agent_id",
|
|
2411
|
+
)
|
|
2412
|
+
|
|
2413
|
+
|
|
2414
|
+
asyncio.run(main())
|
|
2415
|
+
"""
|
|
2416
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
2417
|
+
f"v1/agents/{jsonable_encoder(agent_id)}/messages/cancel",
|
|
2418
|
+
method="POST",
|
|
2419
|
+
json=request,
|
|
2420
|
+
request_options=request_options,
|
|
2421
|
+
omit=OMIT,
|
|
2422
|
+
)
|
|
2423
|
+
try:
|
|
2424
|
+
if 200 <= _response.status_code < 300:
|
|
2425
|
+
return typing.cast(
|
|
2426
|
+
typing.Dict[str, typing.Optional[typing.Any]],
|
|
2427
|
+
construct_type(
|
|
2428
|
+
type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
|
|
2429
|
+
object_=_response.json(),
|
|
2430
|
+
),
|
|
2431
|
+
)
|
|
2432
|
+
if _response.status_code == 422:
|
|
2433
|
+
raise UnprocessableEntityError(
|
|
2434
|
+
typing.cast(
|
|
2435
|
+
HttpValidationError,
|
|
2436
|
+
construct_type(
|
|
2437
|
+
type_=HttpValidationError, # type: ignore
|
|
2438
|
+
object_=_response.json(),
|
|
2439
|
+
),
|
|
2440
|
+
)
|
|
2441
|
+
)
|
|
2442
|
+
_response_json = _response.json()
|
|
2443
|
+
except JSONDecodeError:
|
|
2444
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
2445
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
2446
|
+
|
|
2301
2447
|
async def summarize_agent_conversation(
|
|
2302
2448
|
self, agent_id: str, *, max_message_length: int, request_options: typing.Optional[RequestOptions] = None
|
|
2303
2449
|
) -> AgentState:
|
|
@@ -454,6 +454,9 @@ class MessagesClient:
|
|
|
454
454
|
Asynchronously process a user message and return a run object.
|
|
455
455
|
The actual processing happens in the background, and the status can be checked using the run ID.
|
|
456
456
|
|
|
457
|
+
This is "asynchronous" in the sense that it's a background job and explicitly must be fetched by the run ID.
|
|
458
|
+
This is more like `send_message_job`
|
|
459
|
+
|
|
457
460
|
Parameters
|
|
458
461
|
----------
|
|
459
462
|
agent_id : str
|
|
@@ -1082,6 +1085,9 @@ class AsyncMessagesClient:
|
|
|
1082
1085
|
Asynchronously process a user message and return a run object.
|
|
1083
1086
|
The actual processing happens in the background, and the status can be checked using the run ID.
|
|
1084
1087
|
|
|
1088
|
+
This is "asynchronous" in the sense that it's a background job and explicitly must be fetched by the run ID.
|
|
1089
|
+
This is more like `send_message_job`
|
|
1090
|
+
|
|
1085
1091
|
Parameters
|
|
1086
1092
|
----------
|
|
1087
1093
|
agent_id : str
|
letta_client/client.py
CHANGED
|
@@ -8,6 +8,7 @@ from .base_client import AsyncLettaBase, LettaBase
|
|
|
8
8
|
from .core.request_options import RequestOptions
|
|
9
9
|
from .tools.client import ToolsClient as ToolsClientBase
|
|
10
10
|
from .tools.client import AsyncToolsClient as AsyncToolsClientBase
|
|
11
|
+
from .types.pip_requirement import PipRequirement
|
|
11
12
|
from .types.tool import Tool
|
|
12
13
|
|
|
13
14
|
# this is used as the default value for optional parameters
|
|
@@ -142,6 +143,7 @@ class ToolsClient(ToolsClientBase):
|
|
|
142
143
|
typing.Dict[str, typing.Optional[typing.Any]]
|
|
143
144
|
] = OMIT,
|
|
144
145
|
return_char_limit: typing.Optional[int] = OMIT,
|
|
146
|
+
pip_requirements: typing.Optional[typing.Sequence[PipRequirement]] = OMIT,
|
|
145
147
|
request_options: typing.Optional[RequestOptions] = None,
|
|
146
148
|
) -> Tool:
|
|
147
149
|
"""
|
|
@@ -170,6 +172,9 @@ class ToolsClient(ToolsClientBase):
|
|
|
170
172
|
return_char_limit : typing.Optional[int]
|
|
171
173
|
The maximum number of characters in the response.
|
|
172
174
|
|
|
175
|
+
pip_requirements : typing.Optional[typing.Sequence[PipRequirement]]
|
|
176
|
+
Optional list of pip packages required by this tool.
|
|
177
|
+
|
|
173
178
|
request_options : typing.Optional[RequestOptions]
|
|
174
179
|
Request-specific configuration.
|
|
175
180
|
|
|
@@ -215,6 +220,7 @@ class ToolsClient(ToolsClientBase):
|
|
|
215
220
|
source_type=source_type,
|
|
216
221
|
json_schema=json_schema,
|
|
217
222
|
return_char_limit=return_char_limit,
|
|
223
|
+
pip_requirements=pip_requirements,
|
|
218
224
|
request_options=request_options,
|
|
219
225
|
)
|
|
220
226
|
|
|
@@ -231,6 +237,7 @@ class ToolsClient(ToolsClientBase):
|
|
|
231
237
|
typing.Dict[str, typing.Optional[typing.Any]]
|
|
232
238
|
] = OMIT,
|
|
233
239
|
return_char_limit: typing.Optional[int] = OMIT,
|
|
240
|
+
pip_requirements: typing.Optional[typing.Sequence[PipRequirement]] = OMIT,
|
|
234
241
|
request_options: typing.Optional[RequestOptions] = None,
|
|
235
242
|
) -> Tool:
|
|
236
243
|
"""
|
|
@@ -259,6 +266,9 @@ class ToolsClient(ToolsClientBase):
|
|
|
259
266
|
return_char_limit : typing.Optional[int]
|
|
260
267
|
The maximum number of characters in the response.
|
|
261
268
|
|
|
269
|
+
pip_requirements : typing.Optional[typing.Sequence[PipRequirement]]
|
|
270
|
+
Optional list of pip packages required by this tool.
|
|
271
|
+
|
|
262
272
|
request_options : typing.Optional[RequestOptions]
|
|
263
273
|
Request-specific configuration.
|
|
264
274
|
|
|
@@ -304,6 +314,7 @@ class ToolsClient(ToolsClientBase):
|
|
|
304
314
|
source_type=source_type,
|
|
305
315
|
json_schema=json_schema,
|
|
306
316
|
return_char_limit=return_char_limit,
|
|
317
|
+
pip_requirements=pip_requirements,
|
|
307
318
|
request_options=request_options,
|
|
308
319
|
)
|
|
309
320
|
|
|
@@ -379,6 +390,7 @@ class ToolsClient(ToolsClientBase):
|
|
|
379
390
|
source_type=tool.source_type or OMIT,
|
|
380
391
|
json_schema=tool.json_schema or OMIT,
|
|
381
392
|
return_char_limit=tool.return_char_limit or OMIT,
|
|
393
|
+
pip_requirements=tool.pip_requirements or OMIT,
|
|
382
394
|
request_options=request_options,
|
|
383
395
|
)
|
|
384
396
|
|
|
@@ -397,6 +409,7 @@ class AsyncToolsClient(AsyncToolsClientBase):
|
|
|
397
409
|
typing.Dict[str, typing.Optional[typing.Any]]
|
|
398
410
|
] = OMIT,
|
|
399
411
|
return_char_limit: typing.Optional[int] = OMIT,
|
|
412
|
+
pip_requirements: typing.Optional[typing.Sequence[PipRequirement]] = OMIT,
|
|
400
413
|
request_options: typing.Optional[RequestOptions] = None,
|
|
401
414
|
) -> Tool:
|
|
402
415
|
"""
|
|
@@ -425,6 +438,9 @@ class AsyncToolsClient(AsyncToolsClientBase):
|
|
|
425
438
|
return_char_limit : typing.Optional[int]
|
|
426
439
|
The maximum number of characters in the response.
|
|
427
440
|
|
|
441
|
+
pip_requirements : typing.Optional[typing.Sequence[PipRequirement]]
|
|
442
|
+
Optional list of pip packages required by this tool.
|
|
443
|
+
|
|
428
444
|
request_options : typing.Optional[RequestOptions]
|
|
429
445
|
Request-specific configuration.
|
|
430
446
|
|
|
@@ -470,6 +486,7 @@ class AsyncToolsClient(AsyncToolsClientBase):
|
|
|
470
486
|
source_type=source_type,
|
|
471
487
|
json_schema=json_schema,
|
|
472
488
|
return_char_limit=return_char_limit,
|
|
489
|
+
pip_requirements=pip_requirements,
|
|
473
490
|
request_options=request_options,
|
|
474
491
|
)
|
|
475
492
|
|
|
@@ -486,6 +503,7 @@ class AsyncToolsClient(AsyncToolsClientBase):
|
|
|
486
503
|
typing.Dict[str, typing.Optional[typing.Any]]
|
|
487
504
|
] = OMIT,
|
|
488
505
|
return_char_limit: typing.Optional[int] = OMIT,
|
|
506
|
+
pip_requirements: typing.Optional[typing.Sequence[PipRequirement]] = OMIT,
|
|
489
507
|
request_options: typing.Optional[RequestOptions] = None,
|
|
490
508
|
) -> Tool:
|
|
491
509
|
"""
|
|
@@ -514,6 +532,9 @@ class AsyncToolsClient(AsyncToolsClientBase):
|
|
|
514
532
|
return_char_limit : typing.Optional[int]
|
|
515
533
|
The maximum number of characters in the response.
|
|
516
534
|
|
|
535
|
+
pip_requirements : typing.Optional[typing.Sequence[PipRequirement]]
|
|
536
|
+
Optional list of pip packages required by this tool.
|
|
537
|
+
|
|
517
538
|
request_options : typing.Optional[RequestOptions]
|
|
518
539
|
Request-specific configuration.
|
|
519
540
|
|
|
@@ -559,6 +580,7 @@ class AsyncToolsClient(AsyncToolsClientBase):
|
|
|
559
580
|
source_type=source_type,
|
|
560
581
|
json_schema=json_schema,
|
|
561
582
|
return_char_limit=return_char_limit,
|
|
583
|
+
pip_requirements=pip_requirements,
|
|
562
584
|
request_options=request_options,
|
|
563
585
|
)
|
|
564
586
|
|
|
@@ -634,5 +656,6 @@ class AsyncToolsClient(AsyncToolsClientBase):
|
|
|
634
656
|
source_type=tool.source_type or OMIT,
|
|
635
657
|
json_schema=tool.json_schema or OMIT,
|
|
636
658
|
return_char_limit=tool.return_char_limit or OMIT,
|
|
659
|
+
pip_requirements=tool.pip_requirements or OMIT,
|
|
637
660
|
request_options=request_options,
|
|
638
661
|
)
|
|
@@ -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.
|
|
27
|
+
"X-Fern-SDK-Version": "0.1.189",
|
|
28
28
|
}
|
|
29
29
|
if self._project is not None:
|
|
30
30
|
headers["X-Project"] = self._project
|
letta_client/jobs/client.py
CHANGED
|
@@ -18,16 +18,36 @@ class JobsClient:
|
|
|
18
18
|
self._client_wrapper = client_wrapper
|
|
19
19
|
|
|
20
20
|
def list(
|
|
21
|
-
self,
|
|
21
|
+
self,
|
|
22
|
+
*,
|
|
23
|
+
source_id: typing.Optional[str] = None,
|
|
24
|
+
before: typing.Optional[str] = None,
|
|
25
|
+
after: typing.Optional[str] = None,
|
|
26
|
+
limit: typing.Optional[int] = None,
|
|
27
|
+
ascending: typing.Optional[bool] = None,
|
|
28
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
22
29
|
) -> typing.List[Job]:
|
|
23
30
|
"""
|
|
24
31
|
List all jobs.
|
|
32
|
+
TODO (cliandy): implementation for pagination
|
|
25
33
|
|
|
26
34
|
Parameters
|
|
27
35
|
----------
|
|
28
36
|
source_id : typing.Optional[str]
|
|
29
37
|
Only list jobs associated with the source.
|
|
30
38
|
|
|
39
|
+
before : typing.Optional[str]
|
|
40
|
+
Cursor for pagination
|
|
41
|
+
|
|
42
|
+
after : typing.Optional[str]
|
|
43
|
+
Cursor for pagination
|
|
44
|
+
|
|
45
|
+
limit : typing.Optional[int]
|
|
46
|
+
Limit for pagination
|
|
47
|
+
|
|
48
|
+
ascending : typing.Optional[bool]
|
|
49
|
+
Whether to sort jobs oldest to newest (True, default) or newest to oldest (False)
|
|
50
|
+
|
|
31
51
|
request_options : typing.Optional[RequestOptions]
|
|
32
52
|
Request-specific configuration.
|
|
33
53
|
|
|
@@ -51,6 +71,10 @@ class JobsClient:
|
|
|
51
71
|
method="GET",
|
|
52
72
|
params={
|
|
53
73
|
"source_id": source_id,
|
|
74
|
+
"before": before,
|
|
75
|
+
"after": after,
|
|
76
|
+
"limit": limit,
|
|
77
|
+
"ascending": ascending,
|
|
54
78
|
},
|
|
55
79
|
request_options=request_options,
|
|
56
80
|
)
|
|
@@ -79,7 +103,14 @@ class JobsClient:
|
|
|
79
103
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
80
104
|
|
|
81
105
|
def list_active(
|
|
82
|
-
self,
|
|
106
|
+
self,
|
|
107
|
+
*,
|
|
108
|
+
source_id: typing.Optional[str] = None,
|
|
109
|
+
before: typing.Optional[str] = None,
|
|
110
|
+
after: typing.Optional[str] = None,
|
|
111
|
+
limit: typing.Optional[int] = None,
|
|
112
|
+
ascending: typing.Optional[bool] = None,
|
|
113
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
83
114
|
) -> typing.List[Job]:
|
|
84
115
|
"""
|
|
85
116
|
List all active jobs.
|
|
@@ -89,6 +120,18 @@ class JobsClient:
|
|
|
89
120
|
source_id : typing.Optional[str]
|
|
90
121
|
Only list jobs associated with the source.
|
|
91
122
|
|
|
123
|
+
before : typing.Optional[str]
|
|
124
|
+
Cursor for pagination
|
|
125
|
+
|
|
126
|
+
after : typing.Optional[str]
|
|
127
|
+
Cursor for pagination
|
|
128
|
+
|
|
129
|
+
limit : typing.Optional[int]
|
|
130
|
+
Limit for pagination
|
|
131
|
+
|
|
132
|
+
ascending : typing.Optional[bool]
|
|
133
|
+
Whether to sort jobs oldest to newest (True, default) or newest to oldest (False)
|
|
134
|
+
|
|
92
135
|
request_options : typing.Optional[RequestOptions]
|
|
93
136
|
Request-specific configuration.
|
|
94
137
|
|
|
@@ -112,6 +155,10 @@ class JobsClient:
|
|
|
112
155
|
method="GET",
|
|
113
156
|
params={
|
|
114
157
|
"source_id": source_id,
|
|
158
|
+
"before": before,
|
|
159
|
+
"after": after,
|
|
160
|
+
"limit": limit,
|
|
161
|
+
"ascending": ascending,
|
|
115
162
|
},
|
|
116
163
|
request_options=request_options,
|
|
117
164
|
)
|
|
@@ -253,22 +300,102 @@ class JobsClient:
|
|
|
253
300
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
254
301
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
255
302
|
|
|
303
|
+
def cancel_job(self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Job:
|
|
304
|
+
"""
|
|
305
|
+
Cancel a job by its job_id.
|
|
306
|
+
|
|
307
|
+
This endpoint marks a job as cancelled, which will cause any associated
|
|
308
|
+
agent execution to terminate as soon as possible.
|
|
309
|
+
|
|
310
|
+
Parameters
|
|
311
|
+
----------
|
|
312
|
+
job_id : str
|
|
313
|
+
|
|
314
|
+
request_options : typing.Optional[RequestOptions]
|
|
315
|
+
Request-specific configuration.
|
|
316
|
+
|
|
317
|
+
Returns
|
|
318
|
+
-------
|
|
319
|
+
Job
|
|
320
|
+
Successful Response
|
|
321
|
+
|
|
322
|
+
Examples
|
|
323
|
+
--------
|
|
324
|
+
from letta_client import Letta
|
|
325
|
+
|
|
326
|
+
client = Letta(
|
|
327
|
+
project="YOUR_PROJECT",
|
|
328
|
+
token="YOUR_TOKEN",
|
|
329
|
+
)
|
|
330
|
+
client.jobs.cancel_job(
|
|
331
|
+
job_id="job_id",
|
|
332
|
+
)
|
|
333
|
+
"""
|
|
334
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
335
|
+
f"v1/jobs/{jsonable_encoder(job_id)}/cancel",
|
|
336
|
+
method="PATCH",
|
|
337
|
+
request_options=request_options,
|
|
338
|
+
)
|
|
339
|
+
try:
|
|
340
|
+
if 200 <= _response.status_code < 300:
|
|
341
|
+
return typing.cast(
|
|
342
|
+
Job,
|
|
343
|
+
construct_type(
|
|
344
|
+
type_=Job, # 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
|
+
|
|
256
363
|
|
|
257
364
|
class AsyncJobsClient:
|
|
258
365
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
259
366
|
self._client_wrapper = client_wrapper
|
|
260
367
|
|
|
261
368
|
async def list(
|
|
262
|
-
self,
|
|
369
|
+
self,
|
|
370
|
+
*,
|
|
371
|
+
source_id: typing.Optional[str] = None,
|
|
372
|
+
before: typing.Optional[str] = None,
|
|
373
|
+
after: typing.Optional[str] = None,
|
|
374
|
+
limit: typing.Optional[int] = None,
|
|
375
|
+
ascending: typing.Optional[bool] = None,
|
|
376
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
263
377
|
) -> typing.List[Job]:
|
|
264
378
|
"""
|
|
265
379
|
List all jobs.
|
|
380
|
+
TODO (cliandy): implementation for pagination
|
|
266
381
|
|
|
267
382
|
Parameters
|
|
268
383
|
----------
|
|
269
384
|
source_id : typing.Optional[str]
|
|
270
385
|
Only list jobs associated with the source.
|
|
271
386
|
|
|
387
|
+
before : typing.Optional[str]
|
|
388
|
+
Cursor for pagination
|
|
389
|
+
|
|
390
|
+
after : typing.Optional[str]
|
|
391
|
+
Cursor for pagination
|
|
392
|
+
|
|
393
|
+
limit : typing.Optional[int]
|
|
394
|
+
Limit for pagination
|
|
395
|
+
|
|
396
|
+
ascending : typing.Optional[bool]
|
|
397
|
+
Whether to sort jobs oldest to newest (True, default) or newest to oldest (False)
|
|
398
|
+
|
|
272
399
|
request_options : typing.Optional[RequestOptions]
|
|
273
400
|
Request-specific configuration.
|
|
274
401
|
|
|
@@ -300,6 +427,10 @@ class AsyncJobsClient:
|
|
|
300
427
|
method="GET",
|
|
301
428
|
params={
|
|
302
429
|
"source_id": source_id,
|
|
430
|
+
"before": before,
|
|
431
|
+
"after": after,
|
|
432
|
+
"limit": limit,
|
|
433
|
+
"ascending": ascending,
|
|
303
434
|
},
|
|
304
435
|
request_options=request_options,
|
|
305
436
|
)
|
|
@@ -328,7 +459,14 @@ class AsyncJobsClient:
|
|
|
328
459
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
329
460
|
|
|
330
461
|
async def list_active(
|
|
331
|
-
self,
|
|
462
|
+
self,
|
|
463
|
+
*,
|
|
464
|
+
source_id: typing.Optional[str] = None,
|
|
465
|
+
before: typing.Optional[str] = None,
|
|
466
|
+
after: typing.Optional[str] = None,
|
|
467
|
+
limit: typing.Optional[int] = None,
|
|
468
|
+
ascending: typing.Optional[bool] = None,
|
|
469
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
332
470
|
) -> typing.List[Job]:
|
|
333
471
|
"""
|
|
334
472
|
List all active jobs.
|
|
@@ -338,6 +476,18 @@ class AsyncJobsClient:
|
|
|
338
476
|
source_id : typing.Optional[str]
|
|
339
477
|
Only list jobs associated with the source.
|
|
340
478
|
|
|
479
|
+
before : typing.Optional[str]
|
|
480
|
+
Cursor for pagination
|
|
481
|
+
|
|
482
|
+
after : typing.Optional[str]
|
|
483
|
+
Cursor for pagination
|
|
484
|
+
|
|
485
|
+
limit : typing.Optional[int]
|
|
486
|
+
Limit for pagination
|
|
487
|
+
|
|
488
|
+
ascending : typing.Optional[bool]
|
|
489
|
+
Whether to sort jobs oldest to newest (True, default) or newest to oldest (False)
|
|
490
|
+
|
|
341
491
|
request_options : typing.Optional[RequestOptions]
|
|
342
492
|
Request-specific configuration.
|
|
343
493
|
|
|
@@ -369,6 +519,10 @@ class AsyncJobsClient:
|
|
|
369
519
|
method="GET",
|
|
370
520
|
params={
|
|
371
521
|
"source_id": source_id,
|
|
522
|
+
"before": before,
|
|
523
|
+
"after": after,
|
|
524
|
+
"limit": limit,
|
|
525
|
+
"ascending": ascending,
|
|
372
526
|
},
|
|
373
527
|
request_options=request_options,
|
|
374
528
|
)
|
|
@@ -525,3 +679,71 @@ class AsyncJobsClient:
|
|
|
525
679
|
except JSONDecodeError:
|
|
526
680
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
527
681
|
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
682
|
+
|
|
683
|
+
async def cancel_job(self, job_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Job:
|
|
684
|
+
"""
|
|
685
|
+
Cancel a job by its job_id.
|
|
686
|
+
|
|
687
|
+
This endpoint marks a job as cancelled, which will cause any associated
|
|
688
|
+
agent execution to terminate as soon as possible.
|
|
689
|
+
|
|
690
|
+
Parameters
|
|
691
|
+
----------
|
|
692
|
+
job_id : str
|
|
693
|
+
|
|
694
|
+
request_options : typing.Optional[RequestOptions]
|
|
695
|
+
Request-specific configuration.
|
|
696
|
+
|
|
697
|
+
Returns
|
|
698
|
+
-------
|
|
699
|
+
Job
|
|
700
|
+
Successful Response
|
|
701
|
+
|
|
702
|
+
Examples
|
|
703
|
+
--------
|
|
704
|
+
import asyncio
|
|
705
|
+
|
|
706
|
+
from letta_client import AsyncLetta
|
|
707
|
+
|
|
708
|
+
client = AsyncLetta(
|
|
709
|
+
project="YOUR_PROJECT",
|
|
710
|
+
token="YOUR_TOKEN",
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
async def main() -> None:
|
|
715
|
+
await client.jobs.cancel_job(
|
|
716
|
+
job_id="job_id",
|
|
717
|
+
)
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
asyncio.run(main())
|
|
721
|
+
"""
|
|
722
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
723
|
+
f"v1/jobs/{jsonable_encoder(job_id)}/cancel",
|
|
724
|
+
method="PATCH",
|
|
725
|
+
request_options=request_options,
|
|
726
|
+
)
|
|
727
|
+
try:
|
|
728
|
+
if 200 <= _response.status_code < 300:
|
|
729
|
+
return typing.cast(
|
|
730
|
+
Job,
|
|
731
|
+
construct_type(
|
|
732
|
+
type_=Job, # type: ignore
|
|
733
|
+
object_=_response.json(),
|
|
734
|
+
),
|
|
735
|
+
)
|
|
736
|
+
if _response.status_code == 422:
|
|
737
|
+
raise UnprocessableEntityError(
|
|
738
|
+
typing.cast(
|
|
739
|
+
HttpValidationError,
|
|
740
|
+
construct_type(
|
|
741
|
+
type_=HttpValidationError, # type: ignore
|
|
742
|
+
object_=_response.json(),
|
|
743
|
+
),
|
|
744
|
+
)
|
|
745
|
+
)
|
|
746
|
+
_response_json = _response.json()
|
|
747
|
+
except JSONDecodeError:
|
|
748
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
749
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
import typing
|
|
4
4
|
|
|
5
5
|
StopReasonType = typing.Union[
|
|
6
|
-
typing.Literal["end_turn", "error", "invalid_tool_call", "max_steps", "no_tool_call", "tool_rule"],
|
|
6
|
+
typing.Literal["end_turn", "error", "invalid_tool_call", "max_steps", "no_tool_call", "tool_rule", "cancelled"],
|
|
7
|
+
typing.Any,
|
|
7
8
|
]
|
|
@@ -26,6 +26,11 @@ class UpdateSsemcpServer(UncheckedBaseModel):
|
|
|
26
26
|
The access token or API key for the MCP server (used for SSE authentication)
|
|
27
27
|
"""
|
|
28
28
|
|
|
29
|
+
custom_headers: typing.Optional[typing.Dict[str, typing.Optional[str]]] = pydantic.Field(default=None)
|
|
30
|
+
"""
|
|
31
|
+
Custom authentication headers as key-value pairs
|
|
32
|
+
"""
|
|
33
|
+
|
|
29
34
|
if IS_PYDANTIC_V2:
|
|
30
35
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
31
36
|
else:
|
|
@@ -31,6 +31,11 @@ class UpdateStreamableHttpmcpServer(UncheckedBaseModel):
|
|
|
31
31
|
The authentication token or API key value
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
|
+
custom_headers: typing.Optional[typing.Dict[str, typing.Optional[str]]] = pydantic.Field(default=None)
|
|
35
|
+
"""
|
|
36
|
+
Custom authentication headers as key-value pairs
|
|
37
|
+
"""
|
|
38
|
+
|
|
34
39
|
if IS_PYDANTIC_V2:
|
|
35
40
|
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
|
|
36
41
|
else:
|
|
@@ -2,7 +2,7 @@ letta_client/__init__.py,sha256=qJr7FK3esCAtlSArEc7x1oXME3Eo_eyGJb2MxXE0oRY,1812
|
|
|
2
2
|
letta_client/agents/__init__.py,sha256=9L60SAZIihZzh_KhVxu0uX4RS7z2iKKctzQsS8ycXHc,1954
|
|
3
3
|
letta_client/agents/blocks/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
4
4
|
letta_client/agents/blocks/client.py,sha256=HwUOGmCQ_wuKb3_52ij1BBHRXdzIEd8SjW9-9Rop26Q,25044
|
|
5
|
-
letta_client/agents/client.py,sha256=
|
|
5
|
+
letta_client/agents/client.py,sha256=htBG9I-lsRzykYPaQNwdCjMz-_8-bHwZsD857Iga4H4,98603
|
|
6
6
|
letta_client/agents/context/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
7
7
|
letta_client/agents/context/client.py,sha256=O1gxStQyfzXi4MblatWalLTWM425gS_fndW3W_es08U,4887
|
|
8
8
|
letta_client/agents/core_memory/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
@@ -14,7 +14,7 @@ letta_client/agents/memory_variables/client.py,sha256=DGJvV5k5H-BRE-FWMLNrCqKkHJ
|
|
|
14
14
|
letta_client/agents/memory_variables/types/__init__.py,sha256=EoznK0WvhCyFYd4KDdU-cGDQWpSXmq79BSkqVHN-j7A,180
|
|
15
15
|
letta_client/agents/memory_variables/types/memory_variables_list_response.py,sha256=bsF__n_B4ZXEHzg--OVD6tHHXt_aM-FjHm2x1ZXPnL0,599
|
|
16
16
|
letta_client/agents/messages/__init__.py,sha256=M7Ar6Rmb8we4dfYE6jj3FCL9UvVFy1bNQIPflUXMWHA,243
|
|
17
|
-
letta_client/agents/messages/client.py,sha256=
|
|
17
|
+
letta_client/agents/messages/client.py,sha256=d28wEkWNcqX8kGt4e4NYOkOFNRCkq9XVHvIQshxYuGA,46443
|
|
18
18
|
letta_client/agents/messages/types/__init__.py,sha256=Oc2j0oGOs96IEFf9xsJIkjBjoq3OMtse64YwWv3F9Io,335
|
|
19
19
|
letta_client/agents/messages/types/letta_streaming_response.py,sha256=8VR2F32xjoPFXL4YBvBbAZclaJG4ENPTjk7BrlZkmtw,742
|
|
20
20
|
letta_client/agents/messages/types/messages_modify_request.py,sha256=7C2X3BKye-YDSXOkdEmxxt34seI4jkLK0-govtc4nhg,475
|
|
@@ -53,7 +53,7 @@ letta_client/blocks/__init__.py,sha256=c6SGOs9_YGdydYAzhe5TUiaXq52rpWT1mNMcke8qG
|
|
|
53
53
|
letta_client/blocks/agents/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
54
54
|
letta_client/blocks/agents/client.py,sha256=KBeIrslvPqO4AlYMb3L4iDxvtqsS2GfvPRgzhvxI4Ws,4976
|
|
55
55
|
letta_client/blocks/client.py,sha256=N4wZjI0gCDOQDgquwAnV9FfVPUudxo-js5AEzW8rJz0,32107
|
|
56
|
-
letta_client/client.py,sha256=
|
|
56
|
+
letta_client/client.py,sha256=iXqKTuQ0F9jIjkTwD73apLlLQqUF1IF6V_PhenY_CJo,22470
|
|
57
57
|
letta_client/client_side_access_tokens/__init__.py,sha256=z_wHT4UTBK7RzDIfLpdLMtBJBuuDosqgbzdmx-QME_o,763
|
|
58
58
|
letta_client/client_side_access_tokens/client.py,sha256=0JUMP4g57xaoXY17g1XiPrfQXpIHMcat6hvwF3jGEMw,12416
|
|
59
59
|
letta_client/client_side_access_tokens/types/__init__.py,sha256=7AAjp5mP8-5Eo_1G7ELgkit9TS5ksAd55GfvdqOzU9g,1154
|
|
@@ -65,7 +65,7 @@ letta_client/client_side_access_tokens/types/client_side_access_tokens_create_re
|
|
|
65
65
|
letta_client/client_side_access_tokens/types/client_side_access_tokens_create_response_policy_data_item_access_item.py,sha256=R-H25IpNp9feSrW8Yj3h9O3UTMVvFniQJElogKxLuoE,254
|
|
66
66
|
letta_client/core/__init__.py,sha256=OKbX2aCZXgHCDUsCouqv-OiX32xA6eFFCKIUH9M5Vzk,1591
|
|
67
67
|
letta_client/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
|
|
68
|
-
letta_client/core/client_wrapper.py,sha256=
|
|
68
|
+
letta_client/core/client_wrapper.py,sha256=V3d2ebAmI-LZv6Ice4uVFuQlZONuSfyISp9SAofNbi4,2336
|
|
69
69
|
letta_client/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
|
70
70
|
letta_client/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
|
|
71
71
|
letta_client/core/http_client.py,sha256=Z77OIxIbL4OAB2IDqjRq_sYa5yNYAWfmdhdCSSvh6Y4,19552
|
|
@@ -104,7 +104,7 @@ letta_client/identities/client.py,sha256=UBpA8o40EDuIqVJBlgJfq81D3F4Ky2VfDn0tyQg
|
|
|
104
104
|
letta_client/identities/properties/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
105
105
|
letta_client/identities/properties/client.py,sha256=GCLNQpX8dqGQWNwpZWGvher9vGnG6yFriu91VRPyTnA,6125
|
|
106
106
|
letta_client/jobs/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
107
|
-
letta_client/jobs/client.py,sha256=
|
|
107
|
+
letta_client/jobs/client.py,sha256=1E5D_KqesTYJJNHRpSx_AfOzpIA8x0BQjDxNy1WA0Eg,23282
|
|
108
108
|
letta_client/messages/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
109
109
|
letta_client/messages/client.py,sha256=FzYgQefDEc7iDjzPFlF2U6Btzcso2GNw5wnDBwqMzMw,7264
|
|
110
110
|
letta_client/models/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
@@ -361,7 +361,7 @@ letta_client/types/sse_server_config.py,sha256=IN-FdECflYF-XiIM_fvVOwyDu215Csoix
|
|
|
361
361
|
letta_client/types/stdio_server_config.py,sha256=dEQ7bguiLikGemLxYZJ3JCmmEQgAMsSPO_P52oHZSl0,1091
|
|
362
362
|
letta_client/types/step.py,sha256=0s2j8j_nZ4oqH8BXBOgqycnqblUjR1zq8F1nwcYGBqU,3503
|
|
363
363
|
letta_client/types/step_feedback.py,sha256=JXUkclvJ6C-6ZTgd2lteOxqEyO5KRDNQ8ronBPYMdbo,160
|
|
364
|
-
letta_client/types/stop_reason_type.py,sha256=
|
|
364
|
+
letta_client/types/stop_reason_type.py,sha256=BgrPBP-v9YBOpGmpusQvVQqCLPNOQFl57kVrEpPMRKU,246
|
|
365
365
|
letta_client/types/streamable_http_server_config.py,sha256=ya5IZi_bHa3IW0SIbWuQfKXUqSAPlZ_qGZYXiwl4sh0,1775
|
|
366
366
|
letta_client/types/supervisor_manager.py,sha256=VdR1ySp4k43apxM8Bb5uNoBvADsvz8oMEEtDy2F5K6M,676
|
|
367
367
|
letta_client/types/supervisor_manager_update.py,sha256=UJ_TcWcF_PK152Gni0tgRCe3bthCgJbQHCZIb5LLsL0,711
|
|
@@ -390,8 +390,8 @@ letta_client/types/tool_type.py,sha256=Lrced4b0gDW3IWOhyCPC_dZX6dRUReI8VsutrgRTC
|
|
|
390
390
|
letta_client/types/update_assistant_message.py,sha256=D-51o8uXk3X_2Fb2zJ4KoMeRxPiDWaCb3ugRfjBMCTI,878
|
|
391
391
|
letta_client/types/update_assistant_message_content.py,sha256=rh3DP_SpxyBNnf0EDtoaKmPIPV-cXRSFju33NbHgeF0,247
|
|
392
392
|
letta_client/types/update_reasoning_message.py,sha256=2ejxLRNfVDWBfGQG2-A1JNq-DujOfT7AKXCmyH_RApc,650
|
|
393
|
-
letta_client/types/update_ssemcp_server.py,sha256=
|
|
394
|
-
letta_client/types/update_streamable_httpmcp_server.py,sha256=
|
|
393
|
+
letta_client/types/update_ssemcp_server.py,sha256=J3rZnjOlKGJAuysbV32ZrWj2RJIEx3OvpKYX4eSxhQM,1198
|
|
394
|
+
letta_client/types/update_streamable_httpmcp_server.py,sha256=8zOyQlc583_36_J8KofdPy9_ozln2pTvIaSY8dC5TU4,1344
|
|
395
395
|
letta_client/types/update_system_message.py,sha256=wm2yZUdhRQD5sQhqPiedWZAPECwYvWOvRy1lbALTfCI,779
|
|
396
396
|
letta_client/types/update_user_message.py,sha256=7K0eNqN-ab2v3rR1FW3LLq7IHk6_0C0lv3zhTtthzzs,860
|
|
397
397
|
letta_client/types/update_user_message_content.py,sha256=l6yCwYfrp3_5O7QebeqyZ9fcbnbom8Dva3z9dxUrGXE,243
|
|
@@ -415,6 +415,6 @@ letta_client/types/web_search_options_user_location_approximate.py,sha256=Ywk01J
|
|
|
415
415
|
letta_client/version.py,sha256=bttKLbIhO3UonCYQlqs600zzbQgfhCCMjeXR9WRzid4,79
|
|
416
416
|
letta_client/voice/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
|
417
417
|
letta_client/voice/client.py,sha256=47iQYCuW_qpKI4hM3pYVxn3hw7kgQj3emU1_oRpkRMA,5811
|
|
418
|
-
letta_client-0.1.
|
|
419
|
-
letta_client-0.1.
|
|
420
|
-
letta_client-0.1.
|
|
418
|
+
letta_client-0.1.189.dist-info/METADATA,sha256=qHRY6s2ws72cCIwPcFZwhdNFVOmbU8VumyES7TwPKHA,5177
|
|
419
|
+
letta_client-0.1.189.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
420
|
+
letta_client-0.1.189.dist-info/RECORD,,
|
|
File without changes
|