langgraph-sdk 0.3.2__tar.gz → 0.3.4__tar.gz
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.
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/PKG-INFO +2 -2
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/__init__.py +1 -1
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/client.py +197 -4
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/errors.py +1 -1
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/schema.py +30 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/pyproject.toml +2 -2
- langgraph_sdk-0.3.4/tests/test_crons_client.py +487 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_errors.py +36 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/uv.lock +235 -239
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/.gitignore +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/LICENSE +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/Makefile +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/README.md +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/auth/__init__.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/auth/exceptions.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/auth/types.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/encryption/__init__.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/encryption/types.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/py.typed +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/langgraph_sdk/sse.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/fixtures/response.txt +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_api_parity.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_assistants_client.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_client_stream.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_encryption.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_serde.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_serde_schema.py +0 -0
- {langgraph_sdk-0.3.2 → langgraph_sdk-0.3.4}/tests/test_skip_auto_load_api_key.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langgraph-sdk
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: SDK for interacting with LangGraph API
|
|
5
5
|
Project-URL: Source, https://github.com/langchain-ai/langgraph/tree/main/libs/sdk-py
|
|
6
|
-
Project-URL: Twitter, https://x.com/
|
|
6
|
+
Project-URL: Twitter, https://x.com/LangChain
|
|
7
7
|
Project-URL: Slack, https://www.langchain.com/join-community
|
|
8
8
|
Project-URL: Reddit, https://www.reddit.com/r/LangChain/
|
|
9
9
|
License-Expression: MIT
|
|
@@ -3,6 +3,6 @@ from langgraph_sdk.client import get_client, get_sync_client
|
|
|
3
3
|
from langgraph_sdk.encryption import Encryption
|
|
4
4
|
from langgraph_sdk.encryption.types import EncryptionContext
|
|
5
5
|
|
|
6
|
-
__version__ = "0.3.
|
|
6
|
+
__version__ = "0.3.4"
|
|
7
7
|
|
|
8
8
|
__all__ = ["Auth", "Encryption", "EncryptionContext", "get_client", "get_sync_client"]
|
|
@@ -17,6 +17,7 @@ import re
|
|
|
17
17
|
import sys
|
|
18
18
|
import warnings
|
|
19
19
|
from collections.abc import AsyncIterator, Callable, Iterator, Mapping, Sequence
|
|
20
|
+
from datetime import datetime
|
|
20
21
|
from types import TracebackType
|
|
21
22
|
from typing import (
|
|
22
23
|
Any,
|
|
@@ -2982,6 +2983,8 @@ class CronClient:
|
|
|
2982
2983
|
interrupt_after: All | list[str] | None = None,
|
|
2983
2984
|
webhook: str | None = None,
|
|
2984
2985
|
multitask_strategy: str | None = None,
|
|
2986
|
+
end_time: datetime | None = None,
|
|
2987
|
+
enabled: bool | None = None,
|
|
2985
2988
|
headers: Mapping[str, str] | None = None,
|
|
2986
2989
|
params: QueryParamTypes | None = None,
|
|
2987
2990
|
) -> Run:
|
|
@@ -2992,6 +2995,7 @@ class CronClient:
|
|
|
2992
2995
|
assistant_id: The assistant ID or graph name to use for the cron job.
|
|
2993
2996
|
If using graph name, will default to first assistant created from that graph.
|
|
2994
2997
|
schedule: The cron schedule to execute this job on.
|
|
2998
|
+
Schedules are interpreted in UTC.
|
|
2995
2999
|
input: The input to the graph.
|
|
2996
3000
|
metadata: Metadata to assign to the cron job runs.
|
|
2997
3001
|
config: The configuration for the assistant.
|
|
@@ -3005,6 +3009,8 @@ class CronClient:
|
|
|
3005
3009
|
webhook: Webhook to call after LangGraph API call is done.
|
|
3006
3010
|
multitask_strategy: Multitask strategy to use.
|
|
3007
3011
|
Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
|
|
3012
|
+
end_time: The time to stop running the cron job. If not provided, the cron job will run indefinitely.
|
|
3013
|
+
enabled: Whether the cron job is enabled or not.
|
|
3008
3014
|
headers: Optional custom headers to include with the request.
|
|
3009
3015
|
params: Optional query parameters to include with the request.
|
|
3010
3016
|
|
|
@@ -3025,7 +3031,8 @@ class CronClient:
|
|
|
3025
3031
|
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
|
|
3026
3032
|
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
|
|
3027
3033
|
webhook="https://my.fake.webhook.com",
|
|
3028
|
-
multitask_strategy="interrupt"
|
|
3034
|
+
multitask_strategy="interrupt",
|
|
3035
|
+
enabled=True,
|
|
3029
3036
|
)
|
|
3030
3037
|
```
|
|
3031
3038
|
"""
|
|
@@ -3040,6 +3047,8 @@ class CronClient:
|
|
|
3040
3047
|
"interrupt_before": interrupt_before,
|
|
3041
3048
|
"interrupt_after": interrupt_after,
|
|
3042
3049
|
"webhook": webhook,
|
|
3050
|
+
"end_time": end_time.isoformat() if end_time else None,
|
|
3051
|
+
"enabled": enabled,
|
|
3043
3052
|
}
|
|
3044
3053
|
if multitask_strategy:
|
|
3045
3054
|
payload["multitask_strategy"] = multitask_strategy
|
|
@@ -3066,6 +3075,8 @@ class CronClient:
|
|
|
3066
3075
|
webhook: str | None = None,
|
|
3067
3076
|
on_run_completed: OnCompletionBehavior | None = None,
|
|
3068
3077
|
multitask_strategy: str | None = None,
|
|
3078
|
+
end_time: datetime | None = None,
|
|
3079
|
+
enabled: bool | None = None,
|
|
3069
3080
|
headers: Mapping[str, str] | None = None,
|
|
3070
3081
|
params: QueryParamTypes | None = None,
|
|
3071
3082
|
) -> Run:
|
|
@@ -3075,6 +3086,7 @@ class CronClient:
|
|
|
3075
3086
|
assistant_id: The assistant ID or graph name to use for the cron job.
|
|
3076
3087
|
If using graph name, will default to first assistant created from that graph.
|
|
3077
3088
|
schedule: The cron schedule to execute this job on.
|
|
3089
|
+
Schedules are interpreted in UTC.
|
|
3078
3090
|
input: The input to the graph.
|
|
3079
3091
|
metadata: Metadata to assign to the cron job runs.
|
|
3080
3092
|
config: The configuration for the assistant.
|
|
@@ -3090,6 +3102,8 @@ class CronClient:
|
|
|
3090
3102
|
clean them up. Clients are responsible for cleaning up kept threads.
|
|
3091
3103
|
multitask_strategy: Multitask strategy to use.
|
|
3092
3104
|
Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
|
|
3105
|
+
end_time: The time to stop running the cron job. If not provided, the cron job will run indefinitely.
|
|
3106
|
+
enabled: Whether the cron job is enabled or not.
|
|
3093
3107
|
headers: Optional custom headers to include with the request.
|
|
3094
3108
|
params: Optional query parameters to include with the request.
|
|
3095
3109
|
|
|
@@ -3109,7 +3123,8 @@ class CronClient:
|
|
|
3109
3123
|
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
|
|
3110
3124
|
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
|
|
3111
3125
|
webhook="https://my.fake.webhook.com",
|
|
3112
|
-
multitask_strategy="interrupt"
|
|
3126
|
+
multitask_strategy="interrupt",
|
|
3127
|
+
enabled=True,
|
|
3113
3128
|
)
|
|
3114
3129
|
```
|
|
3115
3130
|
|
|
@@ -3126,6 +3141,8 @@ class CronClient:
|
|
|
3126
3141
|
"interrupt_after": interrupt_after,
|
|
3127
3142
|
"webhook": webhook,
|
|
3128
3143
|
"on_run_completed": on_run_completed,
|
|
3144
|
+
"end_time": end_time.isoformat() if end_time else None,
|
|
3145
|
+
"enabled": enabled,
|
|
3129
3146
|
}
|
|
3130
3147
|
if multitask_strategy:
|
|
3131
3148
|
payload["multitask_strategy"] = multitask_strategy
|
|
@@ -3163,11 +3180,88 @@ class CronClient:
|
|
|
3163
3180
|
"""
|
|
3164
3181
|
await self.http.delete(f"/runs/crons/{cron_id}", headers=headers, params=params)
|
|
3165
3182
|
|
|
3183
|
+
async def update(
|
|
3184
|
+
self,
|
|
3185
|
+
cron_id: str,
|
|
3186
|
+
*,
|
|
3187
|
+
schedule: str | None = None,
|
|
3188
|
+
end_time: datetime | None = None,
|
|
3189
|
+
input: Input | None = None,
|
|
3190
|
+
metadata: Mapping[str, Any] | None = None,
|
|
3191
|
+
config: Config | None = None,
|
|
3192
|
+
context: Context | None = None,
|
|
3193
|
+
webhook: str | None = None,
|
|
3194
|
+
interrupt_before: All | list[str] | None = None,
|
|
3195
|
+
interrupt_after: All | list[str] | None = None,
|
|
3196
|
+
on_run_completed: OnCompletionBehavior | None = None,
|
|
3197
|
+
enabled: bool | None = None,
|
|
3198
|
+
headers: Mapping[str, str] | None = None,
|
|
3199
|
+
params: QueryParamTypes | None = None,
|
|
3200
|
+
) -> Cron:
|
|
3201
|
+
"""Update a cron job by ID.
|
|
3202
|
+
|
|
3203
|
+
Args:
|
|
3204
|
+
cron_id: The cron ID to update.
|
|
3205
|
+
schedule: The cron schedule to execute this job on.
|
|
3206
|
+
Schedules are interpreted in UTC.
|
|
3207
|
+
end_time: The end date to stop running the cron.
|
|
3208
|
+
input: The input to the graph.
|
|
3209
|
+
metadata: Metadata to assign to the cron job runs.
|
|
3210
|
+
config: The configuration for the assistant.
|
|
3211
|
+
context: Static context added to the assistant.
|
|
3212
|
+
webhook: Webhook to call after LangGraph API call is done.
|
|
3213
|
+
interrupt_before: Nodes to interrupt immediately before they get executed.
|
|
3214
|
+
interrupt_after: Nodes to interrupt immediately after they get executed.
|
|
3215
|
+
on_run_completed: What to do with the thread after the run completes.
|
|
3216
|
+
Must be one of 'delete' or 'keep'. 'delete' removes the thread
|
|
3217
|
+
after execution. 'keep' creates a new thread for each execution but does not
|
|
3218
|
+
clean them up.
|
|
3219
|
+
enabled: Enable or disable the cron job.
|
|
3220
|
+
headers: Optional custom headers to include with the request.
|
|
3221
|
+
params: Optional query parameters to include with the request.
|
|
3222
|
+
|
|
3223
|
+
Returns:
|
|
3224
|
+
The updated cron job.
|
|
3225
|
+
|
|
3226
|
+
???+ example "Example Usage"
|
|
3227
|
+
|
|
3228
|
+
```python
|
|
3229
|
+
client = get_client(url="http://localhost:2024")
|
|
3230
|
+
updated_cron = await client.crons.update(
|
|
3231
|
+
cron_id="1ef3cefa-4c09-6926-96d0-3dc97fd5e39b",
|
|
3232
|
+
schedule="0 10 * * *",
|
|
3233
|
+
enabled=False,
|
|
3234
|
+
)
|
|
3235
|
+
```
|
|
3236
|
+
|
|
3237
|
+
"""
|
|
3238
|
+
payload = {
|
|
3239
|
+
"schedule": schedule,
|
|
3240
|
+
"end_time": end_time.isoformat() if end_time else None,
|
|
3241
|
+
"input": input,
|
|
3242
|
+
"metadata": metadata,
|
|
3243
|
+
"config": config,
|
|
3244
|
+
"context": context,
|
|
3245
|
+
"webhook": webhook,
|
|
3246
|
+
"interrupt_before": interrupt_before,
|
|
3247
|
+
"interrupt_after": interrupt_after,
|
|
3248
|
+
"on_run_completed": on_run_completed,
|
|
3249
|
+
"enabled": enabled,
|
|
3250
|
+
}
|
|
3251
|
+
payload = {k: v for k, v in payload.items() if v is not None}
|
|
3252
|
+
return await self.http.patch(
|
|
3253
|
+
f"/runs/crons/{cron_id}",
|
|
3254
|
+
json=payload,
|
|
3255
|
+
headers=headers,
|
|
3256
|
+
params=params,
|
|
3257
|
+
)
|
|
3258
|
+
|
|
3166
3259
|
async def search(
|
|
3167
3260
|
self,
|
|
3168
3261
|
*,
|
|
3169
3262
|
assistant_id: str | None = None,
|
|
3170
3263
|
thread_id: str | None = None,
|
|
3264
|
+
enabled: bool | None = None,
|
|
3171
3265
|
limit: int = 10,
|
|
3172
3266
|
offset: int = 0,
|
|
3173
3267
|
sort_by: CronSortBy | None = None,
|
|
@@ -3181,6 +3275,7 @@ class CronClient:
|
|
|
3181
3275
|
Args:
|
|
3182
3276
|
assistant_id: The assistant ID or graph name to search for.
|
|
3183
3277
|
thread_id: the thread ID to search for.
|
|
3278
|
+
enabled: The enabled status to search for.
|
|
3184
3279
|
limit: The maximum number of results to return.
|
|
3185
3280
|
offset: The number of results to skip.
|
|
3186
3281
|
headers: Optional custom headers to include with the request.
|
|
@@ -3196,6 +3291,7 @@ class CronClient:
|
|
|
3196
3291
|
cron_jobs = await client.crons.search(
|
|
3197
3292
|
assistant_id="my_assistant_id",
|
|
3198
3293
|
thread_id="my_thread_id",
|
|
3294
|
+
enabled=True,
|
|
3199
3295
|
limit=5,
|
|
3200
3296
|
offset=5,
|
|
3201
3297
|
)
|
|
@@ -3230,6 +3326,7 @@ class CronClient:
|
|
|
3230
3326
|
payload = {
|
|
3231
3327
|
"assistant_id": assistant_id,
|
|
3232
3328
|
"thread_id": thread_id,
|
|
3329
|
+
"enabled": enabled,
|
|
3233
3330
|
"limit": limit,
|
|
3234
3331
|
"offset": offset,
|
|
3235
3332
|
}
|
|
@@ -6284,6 +6381,8 @@ class SyncCronClient:
|
|
|
6284
6381
|
interrupt_after: All | list[str] | None = None,
|
|
6285
6382
|
webhook: str | None = None,
|
|
6286
6383
|
multitask_strategy: str | None = None,
|
|
6384
|
+
end_time: datetime | None = None,
|
|
6385
|
+
enabled: bool | None = None,
|
|
6287
6386
|
headers: Mapping[str, str] | None = None,
|
|
6288
6387
|
params: QueryParamTypes | None = None,
|
|
6289
6388
|
) -> Run:
|
|
@@ -6294,6 +6393,7 @@ class SyncCronClient:
|
|
|
6294
6393
|
assistant_id: The assistant ID or graph name to use for the cron job.
|
|
6295
6394
|
If using graph name, will default to first assistant created from that graph.
|
|
6296
6395
|
schedule: The cron schedule to execute this job on.
|
|
6396
|
+
Schedules are interpreted in UTC.
|
|
6297
6397
|
input: The input to the graph.
|
|
6298
6398
|
metadata: Metadata to assign to the cron job runs.
|
|
6299
6399
|
config: The configuration for the assistant.
|
|
@@ -6305,6 +6405,8 @@ class SyncCronClient:
|
|
|
6305
6405
|
webhook: Webhook to call after LangGraph API call is done.
|
|
6306
6406
|
multitask_strategy: Multitask strategy to use.
|
|
6307
6407
|
Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
|
|
6408
|
+
end_time: The time to stop running the cron job. If not provided, the cron job will run indefinitely.
|
|
6409
|
+
enabled: Whether the cron job is enabled. By default, it is considered enabled.
|
|
6308
6410
|
headers: Optional custom headers to include with the request.
|
|
6309
6411
|
|
|
6310
6412
|
Returns:
|
|
@@ -6324,7 +6426,8 @@ class SyncCronClient:
|
|
|
6324
6426
|
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
|
|
6325
6427
|
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
|
|
6326
6428
|
webhook="https://my.fake.webhook.com",
|
|
6327
|
-
multitask_strategy="interrupt"
|
|
6429
|
+
multitask_strategy="interrupt",
|
|
6430
|
+
enabled=True
|
|
6328
6431
|
)
|
|
6329
6432
|
```
|
|
6330
6433
|
"""
|
|
@@ -6340,6 +6443,8 @@ class SyncCronClient:
|
|
|
6340
6443
|
"checkpoint_during": checkpoint_during,
|
|
6341
6444
|
"webhook": webhook,
|
|
6342
6445
|
"multitask_strategy": multitask_strategy,
|
|
6446
|
+
"end_time": end_time.isoformat() if end_time else None,
|
|
6447
|
+
"enabled": enabled,
|
|
6343
6448
|
}
|
|
6344
6449
|
payload = {k: v for k, v in payload.items() if v is not None}
|
|
6345
6450
|
return self.http.post(
|
|
@@ -6364,6 +6469,8 @@ class SyncCronClient:
|
|
|
6364
6469
|
webhook: str | None = None,
|
|
6365
6470
|
on_run_completed: OnCompletionBehavior | None = None,
|
|
6366
6471
|
multitask_strategy: str | None = None,
|
|
6472
|
+
end_time: datetime | None = None,
|
|
6473
|
+
enabled: bool | None = None,
|
|
6367
6474
|
headers: Mapping[str, str] | None = None,
|
|
6368
6475
|
params: QueryParamTypes | None = None,
|
|
6369
6476
|
) -> Run:
|
|
@@ -6373,6 +6480,7 @@ class SyncCronClient:
|
|
|
6373
6480
|
assistant_id: The assistant ID or graph name to use for the cron job.
|
|
6374
6481
|
If using graph name, will default to first assistant created from that graph.
|
|
6375
6482
|
schedule: The cron schedule to execute this job on.
|
|
6483
|
+
Schedules are interpreted in UTC.
|
|
6376
6484
|
input: The input to the graph.
|
|
6377
6485
|
metadata: Metadata to assign to the cron job runs.
|
|
6378
6486
|
config: The configuration for the assistant.
|
|
@@ -6388,6 +6496,8 @@ class SyncCronClient:
|
|
|
6388
6496
|
clean them up. Clients are responsible for cleaning up kept threads.
|
|
6389
6497
|
multitask_strategy: Multitask strategy to use.
|
|
6390
6498
|
Must be one of 'reject', 'interrupt', 'rollback', or 'enqueue'.
|
|
6499
|
+
end_time: The time to stop running the cron job. If not provided, the cron job will run indefinitely.
|
|
6500
|
+
enabled: Whether the cron job is enabled. By default, it is considered enabled.
|
|
6391
6501
|
headers: Optional custom headers to include with the request.
|
|
6392
6502
|
|
|
6393
6503
|
Returns:
|
|
@@ -6407,7 +6517,8 @@ class SyncCronClient:
|
|
|
6407
6517
|
interrupt_before=["node_to_stop_before_1","node_to_stop_before_2"],
|
|
6408
6518
|
interrupt_after=["node_to_stop_after_1","node_to_stop_after_2"],
|
|
6409
6519
|
webhook="https://my.fake.webhook.com",
|
|
6410
|
-
multitask_strategy="interrupt"
|
|
6520
|
+
multitask_strategy="interrupt",
|
|
6521
|
+
enabled=True
|
|
6411
6522
|
)
|
|
6412
6523
|
```
|
|
6413
6524
|
|
|
@@ -6425,6 +6536,8 @@ class SyncCronClient:
|
|
|
6425
6536
|
"checkpoint_during": checkpoint_during,
|
|
6426
6537
|
"on_run_completed": on_run_completed,
|
|
6427
6538
|
"multitask_strategy": multitask_strategy,
|
|
6539
|
+
"end_time": end_time.isoformat() if end_time else None,
|
|
6540
|
+
"enabled": enabled,
|
|
6428
6541
|
}
|
|
6429
6542
|
payload = {k: v for k, v in payload.items() if v is not None}
|
|
6430
6543
|
return self.http.post(
|
|
@@ -6460,11 +6573,88 @@ class SyncCronClient:
|
|
|
6460
6573
|
"""
|
|
6461
6574
|
self.http.delete(f"/runs/crons/{cron_id}", headers=headers, params=params)
|
|
6462
6575
|
|
|
6576
|
+
def update(
|
|
6577
|
+
self,
|
|
6578
|
+
cron_id: str,
|
|
6579
|
+
*,
|
|
6580
|
+
schedule: str | None = None,
|
|
6581
|
+
end_time: datetime | None = None,
|
|
6582
|
+
input: Input | None = None,
|
|
6583
|
+
metadata: Mapping[str, Any] | None = None,
|
|
6584
|
+
config: Config | None = None,
|
|
6585
|
+
context: Context | None = None,
|
|
6586
|
+
webhook: str | None = None,
|
|
6587
|
+
interrupt_before: All | list[str] | None = None,
|
|
6588
|
+
interrupt_after: All | list[str] | None = None,
|
|
6589
|
+
on_run_completed: OnCompletionBehavior | None = None,
|
|
6590
|
+
enabled: bool | None = None,
|
|
6591
|
+
headers: Mapping[str, str] | None = None,
|
|
6592
|
+
params: QueryParamTypes | None = None,
|
|
6593
|
+
) -> Cron:
|
|
6594
|
+
"""Update a cron job by ID.
|
|
6595
|
+
|
|
6596
|
+
Args:
|
|
6597
|
+
cron_id: The cron ID to update.
|
|
6598
|
+
schedule: The cron schedule to execute this job on.
|
|
6599
|
+
Schedules are interpreted in UTC.
|
|
6600
|
+
end_time: The end date to stop running the cron.
|
|
6601
|
+
input: The input to the graph.
|
|
6602
|
+
metadata: Metadata to assign to the cron job runs.
|
|
6603
|
+
config: The configuration for the assistant.
|
|
6604
|
+
context: Static context added to the assistant.
|
|
6605
|
+
webhook: Webhook to call after LangGraph API call is done.
|
|
6606
|
+
interrupt_before: Nodes to interrupt immediately before they get executed.
|
|
6607
|
+
interrupt_after: Nodes to interrupt immediately after they get executed.
|
|
6608
|
+
on_run_completed: What to do with the thread after the run completes.
|
|
6609
|
+
Must be one of 'delete' or 'keep'. 'delete' removes the thread
|
|
6610
|
+
after execution. 'keep' creates a new thread for each execution but does not
|
|
6611
|
+
clean them up.
|
|
6612
|
+
enabled: Enable or disable the cron job.
|
|
6613
|
+
headers: Optional custom headers to include with the request.
|
|
6614
|
+
params: Optional query parameters to include with the request.
|
|
6615
|
+
|
|
6616
|
+
Returns:
|
|
6617
|
+
The updated cron job.
|
|
6618
|
+
|
|
6619
|
+
???+ example "Example Usage"
|
|
6620
|
+
|
|
6621
|
+
```python
|
|
6622
|
+
client = get_sync_client(url="http://localhost:8123")
|
|
6623
|
+
updated_cron = client.crons.update(
|
|
6624
|
+
cron_id="1ef3cefa-4c09-6926-96d0-3dc97fd5e39b",
|
|
6625
|
+
schedule="0 10 * * *",
|
|
6626
|
+
enabled=False,
|
|
6627
|
+
)
|
|
6628
|
+
```
|
|
6629
|
+
|
|
6630
|
+
"""
|
|
6631
|
+
payload = {
|
|
6632
|
+
"schedule": schedule,
|
|
6633
|
+
"end_time": end_time.isoformat() if end_time else None,
|
|
6634
|
+
"input": input,
|
|
6635
|
+
"metadata": metadata,
|
|
6636
|
+
"config": config,
|
|
6637
|
+
"context": context,
|
|
6638
|
+
"webhook": webhook,
|
|
6639
|
+
"interrupt_before": interrupt_before,
|
|
6640
|
+
"interrupt_after": interrupt_after,
|
|
6641
|
+
"on_run_completed": on_run_completed,
|
|
6642
|
+
"enabled": enabled,
|
|
6643
|
+
}
|
|
6644
|
+
payload = {k: v for k, v in payload.items() if v is not None}
|
|
6645
|
+
return self.http.patch(
|
|
6646
|
+
f"/runs/crons/{cron_id}",
|
|
6647
|
+
json=payload,
|
|
6648
|
+
headers=headers,
|
|
6649
|
+
params=params,
|
|
6650
|
+
)
|
|
6651
|
+
|
|
6463
6652
|
def search(
|
|
6464
6653
|
self,
|
|
6465
6654
|
*,
|
|
6466
6655
|
assistant_id: str | None = None,
|
|
6467
6656
|
thread_id: str | None = None,
|
|
6657
|
+
enabled: bool | None = None,
|
|
6468
6658
|
limit: int = 10,
|
|
6469
6659
|
offset: int = 0,
|
|
6470
6660
|
sort_by: CronSortBy | None = None,
|
|
@@ -6478,6 +6668,7 @@ class SyncCronClient:
|
|
|
6478
6668
|
Args:
|
|
6479
6669
|
assistant_id: The assistant ID or graph name to search for.
|
|
6480
6670
|
thread_id: the thread ID to search for.
|
|
6671
|
+
enabled: Whether the cron job is enabled.
|
|
6481
6672
|
limit: The maximum number of results to return.
|
|
6482
6673
|
offset: The number of results to skip.
|
|
6483
6674
|
headers: Optional custom headers to include with the request.
|
|
@@ -6492,6 +6683,7 @@ class SyncCronClient:
|
|
|
6492
6683
|
cron_jobs = client.crons.search(
|
|
6493
6684
|
assistant_id="my_assistant_id",
|
|
6494
6685
|
thread_id="my_thread_id",
|
|
6686
|
+
enabled=True,
|
|
6495
6687
|
limit=5,
|
|
6496
6688
|
offset=5,
|
|
6497
6689
|
)
|
|
@@ -6525,6 +6717,7 @@ class SyncCronClient:
|
|
|
6525
6717
|
payload = {
|
|
6526
6718
|
"assistant_id": assistant_id,
|
|
6527
6719
|
"thread_id": thread_id,
|
|
6720
|
+
"enabled": enabled,
|
|
6528
6721
|
"limit": limit,
|
|
6529
6722
|
"offset": offset,
|
|
6530
6723
|
}
|
|
@@ -38,7 +38,7 @@ class APIError(httpx.HTTPStatusError, LangGraphError):
|
|
|
38
38
|
response = None
|
|
39
39
|
|
|
40
40
|
httpx.HTTPStatusError.__init__(self, message, request=req, response=response) # type: ignore[arg-type]
|
|
41
|
-
LangGraphError.__init__(self)
|
|
41
|
+
LangGraphError.__init__(self, message)
|
|
42
42
|
|
|
43
43
|
self.request = req
|
|
44
44
|
self.message = message
|
|
@@ -372,6 +372,35 @@ class Cron(TypedDict):
|
|
|
372
372
|
"""The next run date of the cron."""
|
|
373
373
|
metadata: dict
|
|
374
374
|
"""The metadata of the cron."""
|
|
375
|
+
enabled: bool
|
|
376
|
+
"""Whether the cron is enabled."""
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
class CronUpdate(TypedDict, total=False):
|
|
380
|
+
"""Payload for updating a cron job. All fields are optional."""
|
|
381
|
+
|
|
382
|
+
schedule: str
|
|
383
|
+
"""The cron schedule to execute this job on."""
|
|
384
|
+
end_time: datetime
|
|
385
|
+
"""The end date to stop running the cron."""
|
|
386
|
+
input: Input
|
|
387
|
+
"""The input to the graph."""
|
|
388
|
+
metadata: dict[str, Any]
|
|
389
|
+
"""Metadata to assign to the cron job runs."""
|
|
390
|
+
config: Config
|
|
391
|
+
"""The configuration for the assistant."""
|
|
392
|
+
context: Context
|
|
393
|
+
"""Static context added to the assistant."""
|
|
394
|
+
webhook: str
|
|
395
|
+
"""Webhook to call after LangGraph API call is done."""
|
|
396
|
+
interrupt_before: All | list[str]
|
|
397
|
+
"""Nodes to interrupt immediately before they get executed."""
|
|
398
|
+
interrupt_after: All | list[str]
|
|
399
|
+
"""Nodes to interrupt immediately after they get executed."""
|
|
400
|
+
on_run_completed: OnCompletionBehavior
|
|
401
|
+
"""What to do with the thread after the run completes."""
|
|
402
|
+
enabled: bool
|
|
403
|
+
"""Enable or disable the cron job."""
|
|
375
404
|
|
|
376
405
|
|
|
377
406
|
# Select field aliases for client-side typing of `select` parameters.
|
|
@@ -428,6 +457,7 @@ CronSelectField = Literal[
|
|
|
428
457
|
"metadata",
|
|
429
458
|
"now",
|
|
430
459
|
"on_run_completed",
|
|
460
|
+
"enabled",
|
|
431
461
|
]
|
|
432
462
|
|
|
433
463
|
PrimitiveData = str | int | float | bool | None
|
|
@@ -18,7 +18,7 @@ path = "langgraph_sdk/__init__.py"
|
|
|
18
18
|
|
|
19
19
|
[project.urls]
|
|
20
20
|
Source = "https://github.com/langchain-ai/langgraph/tree/main/libs/sdk-py"
|
|
21
|
-
Twitter = "https://x.com/
|
|
21
|
+
Twitter = "https://x.com/LangChain"
|
|
22
22
|
Slack = "https://www.langchain.com/join-community"
|
|
23
23
|
Reddit = "https://www.reddit.com/r/LangChain/"
|
|
24
24
|
|
|
@@ -30,7 +30,7 @@ test = [
|
|
|
30
30
|
"pytest-watch",
|
|
31
31
|
]
|
|
32
32
|
lint = [
|
|
33
|
-
"ruff==0.14.
|
|
33
|
+
"ruff==0.14.11",
|
|
34
34
|
"codespell",
|
|
35
35
|
"mypy==1.19.0",
|
|
36
36
|
"ty==0.0.1a27",
|