langgraph-sdk 0.2.4__tar.gz → 0.2.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-sdk
3
- Version: 0.2.4
3
+ Version: 0.2.6
4
4
  Summary: SDK for interacting with LangGraph API
5
5
  Project-URL: Repository, https://www.github.com/langchain-ai/langgraph
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  from langgraph_sdk.auth import Auth
2
2
  from langgraph_sdk.client import get_client, get_sync_client
3
3
 
4
- __version__ = "0.2.4"
4
+ __version__ = "0.2.6"
5
5
 
6
6
  __all__ = ["Auth", "get_client", "get_sync_client"]
@@ -400,6 +400,20 @@ class AuthContext(BaseAuthContext):
400
400
  """
401
401
 
402
402
 
403
+ class ThreadTTL(typing.TypedDict, total=False):
404
+ """Time-to-live configuration for a thread.
405
+
406
+ Matches the OpenAPI schema where TTL is represented as an object with
407
+ an optional strategy and a time value in minutes.
408
+ """
409
+
410
+ strategy: typing.Literal["delete"]
411
+ """TTL strategy. Currently only 'delete' is supported."""
412
+
413
+ ttl: int
414
+ """Time-to-live in minutes from now until the thread should be swept."""
415
+
416
+
403
417
  class ThreadsCreate(typing.TypedDict, total=False):
404
418
  """Parameters for creating a new thread.
405
419
 
@@ -422,6 +436,9 @@ class ThreadsCreate(typing.TypedDict, total=False):
422
436
  if_exists: OnConflictBehavior
423
437
  """Behavior when a thread with the same ID already exists."""
424
438
 
439
+ ttl: ThreadTTL
440
+ """Optional TTL configuration for the thread."""
441
+
425
442
 
426
443
  class ThreadsRead(typing.TypedDict, total=False):
427
444
  """Parameters for reading thread state or run information.
@@ -489,6 +506,9 @@ class ThreadsSearch(typing.TypedDict, total=False):
489
506
  offset: int
490
507
  """Offset for pagination."""
491
508
 
509
+ ids: Sequence[UUID] | None
510
+ """typing.Optional list of thread IDs to filter by."""
511
+
492
512
  thread_id: UUID | None
493
513
  """typing.Optional thread ID to filter by."""
494
514
 
@@ -1179,6 +1179,7 @@ class ThreadsClient:
1179
1179
  if_exists: OnConflictBehavior | None = None,
1180
1180
  supersteps: Sequence[dict[str, Sequence[dict[str, Any]]]] | None = None,
1181
1181
  graph_id: str | None = None,
1182
+ ttl: int | Mapping[str, Any] | None = None,
1182
1183
  headers: Mapping[str, str] | None = None,
1183
1184
  params: QueryParamTypes | None = None,
1184
1185
  ) -> Thread:
@@ -1193,6 +1194,9 @@ class ThreadsClient:
1193
1194
  supersteps: Apply a list of supersteps when creating a thread, each containing a sequence of updates.
1194
1195
  Each update has `values` or `command` and `as_node`. Used for copying a thread between deployments.
1195
1196
  graph_id: Optional graph ID to associate with the thread.
1197
+ ttl: Optional time-to-live in minutes for the thread. You can pass an
1198
+ integer (minutes) or a mapping with keys `ttl` and optional
1199
+ `strategy` (defaults to "delete").
1196
1200
  headers: Optional custom headers to include with the request.
1197
1201
  params: Optional query parameters to include with the request.
1198
1202
 
@@ -1234,6 +1238,11 @@ class ThreadsClient:
1234
1238
  }
1235
1239
  for s in supersteps
1236
1240
  ]
1241
+ if ttl is not None:
1242
+ if isinstance(ttl, (int, float)):
1243
+ payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
1244
+ else:
1245
+ payload["ttl"] = ttl
1237
1246
 
1238
1247
  return await self.http.post(
1239
1248
  "/threads", json=payload, headers=headers, params=params
@@ -1244,6 +1253,7 @@ class ThreadsClient:
1244
1253
  thread_id: str,
1245
1254
  *,
1246
1255
  metadata: Mapping[str, Any],
1256
+ ttl: int | Mapping[str, Any] | None = None,
1247
1257
  headers: Mapping[str, str] | None = None,
1248
1258
  params: QueryParamTypes | None = None,
1249
1259
  ) -> Thread:
@@ -1252,6 +1262,9 @@ class ThreadsClient:
1252
1262
  Args:
1253
1263
  thread_id: ID of thread to update.
1254
1264
  metadata: Metadata to merge with existing thread metadata.
1265
+ ttl: Optional time-to-live in minutes for the thread. You can pass an
1266
+ integer (minutes) or a mapping with keys `ttl` and optional
1267
+ `strategy` (defaults to "delete").
1255
1268
  headers: Optional custom headers to include with the request.
1256
1269
  params: Optional query parameters to include with the request.
1257
1270
 
@@ -1265,12 +1278,19 @@ class ThreadsClient:
1265
1278
  thread = await client.threads.update(
1266
1279
  thread_id="my-thread-id",
1267
1280
  metadata={"number":1},
1281
+ ttl=43_200,
1268
1282
  )
1269
1283
  ```
1270
1284
  """ # noqa: E501
1285
+ payload: dict[str, Any] = {"metadata": metadata}
1286
+ if ttl is not None:
1287
+ if isinstance(ttl, (int, float)):
1288
+ payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
1289
+ else:
1290
+ payload["ttl"] = ttl
1271
1291
  return await self.http.patch(
1272
1292
  f"/threads/{thread_id}",
1273
- json={"metadata": metadata},
1293
+ json=payload,
1274
1294
  headers=headers,
1275
1295
  params=params,
1276
1296
  )
@@ -1309,6 +1329,7 @@ class ThreadsClient:
1309
1329
  *,
1310
1330
  metadata: Json = None,
1311
1331
  values: Json = None,
1332
+ ids: Sequence[str] | None = None,
1312
1333
  status: ThreadStatus | None = None,
1313
1334
  limit: int = 10,
1314
1335
  offset: int = 0,
@@ -1323,6 +1344,7 @@ class ThreadsClient:
1323
1344
  Args:
1324
1345
  metadata: Thread metadata to filter on.
1325
1346
  values: State values to filter on.
1347
+ ids: List of thread IDs to filter by.
1326
1348
  status: Thread status to filter on.
1327
1349
  Must be one of 'idle', 'busy', 'interrupted' or 'error'.
1328
1350
  limit: Limit on number of threads to return.
@@ -1356,6 +1378,8 @@ class ThreadsClient:
1356
1378
  payload["metadata"] = metadata
1357
1379
  if values:
1358
1380
  payload["values"] = values
1381
+ if ids:
1382
+ payload["ids"] = ids
1359
1383
  if status:
1360
1384
  payload["status"] = status
1361
1385
  if sort_by:
@@ -4328,6 +4352,7 @@ class SyncThreadsClient:
4328
4352
  if_exists: OnConflictBehavior | None = None,
4329
4353
  supersteps: Sequence[dict[str, Sequence[dict[str, Any]]]] | None = None,
4330
4354
  graph_id: str | None = None,
4355
+ ttl: int | Mapping[str, Any] | None = None,
4331
4356
  headers: Mapping[str, str] | None = None,
4332
4357
  params: QueryParamTypes | None = None,
4333
4358
  ) -> Thread:
@@ -4342,6 +4367,9 @@ class SyncThreadsClient:
4342
4367
  supersteps: Apply a list of supersteps when creating a thread, each containing a sequence of updates.
4343
4368
  Each update has `values` or `command` and `as_node`. Used for copying a thread between deployments.
4344
4369
  graph_id: Optional graph ID to associate with the thread.
4370
+ ttl: Optional time-to-live in minutes for the thread. You can pass an
4371
+ integer (minutes) or a mapping with keys `ttl` and optional
4372
+ `strategy` (defaults to "delete").
4345
4373
  headers: Optional custom headers to include with the request.
4346
4374
 
4347
4375
  Returns:
@@ -4383,6 +4411,11 @@ class SyncThreadsClient:
4383
4411
  }
4384
4412
  for s in supersteps
4385
4413
  ]
4414
+ if ttl is not None:
4415
+ if isinstance(ttl, (int, float)):
4416
+ payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
4417
+ else:
4418
+ payload["ttl"] = ttl
4386
4419
 
4387
4420
  return self.http.post("/threads", json=payload, headers=headers, params=params)
4388
4421
 
@@ -4391,6 +4424,7 @@ class SyncThreadsClient:
4391
4424
  thread_id: str,
4392
4425
  *,
4393
4426
  metadata: Mapping[str, Any],
4427
+ ttl: int | Mapping[str, Any] | None = None,
4394
4428
  headers: Mapping[str, str] | None = None,
4395
4429
  params: QueryParamTypes | None = None,
4396
4430
  ) -> Thread:
@@ -4399,7 +4433,11 @@ class SyncThreadsClient:
4399
4433
  Args:
4400
4434
  thread_id: ID of thread to update.
4401
4435
  metadata: Metadata to merge with existing thread metadata.
4436
+ ttl: Optional time-to-live in minutes for the thread. You can pass an
4437
+ integer (minutes) or a mapping with keys `ttl` and optional
4438
+ `strategy` (defaults to "delete").
4402
4439
  headers: Optional custom headers to include with the request.
4440
+ params: Optional query parameters to include with the request.
4403
4441
 
4404
4442
  Returns:
4405
4443
  Thread: The created thread.
@@ -4411,12 +4449,19 @@ class SyncThreadsClient:
4411
4449
  thread = client.threads.update(
4412
4450
  thread_id="my-thread-id",
4413
4451
  metadata={"number":1},
4452
+ ttl=43_200,
4414
4453
  )
4415
4454
  ```
4416
4455
  """ # noqa: E501
4456
+ payload: dict[str, Any] = {"metadata": metadata}
4457
+ if ttl is not None:
4458
+ if isinstance(ttl, (int, float)):
4459
+ payload["ttl"] = {"ttl": ttl, "strategy": "delete"}
4460
+ else:
4461
+ payload["ttl"] = ttl
4417
4462
  return self.http.patch(
4418
4463
  f"/threads/{thread_id}",
4419
- json={"metadata": metadata},
4464
+ json=payload,
4420
4465
  headers=headers,
4421
4466
  params=params,
4422
4467
  )
@@ -4454,6 +4499,7 @@ class SyncThreadsClient:
4454
4499
  *,
4455
4500
  metadata: Json = None,
4456
4501
  values: Json = None,
4502
+ ids: Sequence[str] | None = None,
4457
4503
  status: ThreadStatus | None = None,
4458
4504
  limit: int = 10,
4459
4505
  offset: int = 0,
@@ -4468,6 +4514,7 @@ class SyncThreadsClient:
4468
4514
  Args:
4469
4515
  metadata: Thread metadata to filter on.
4470
4516
  values: State values to filter on.
4517
+ ids: List of thread IDs to filter by.
4471
4518
  status: Thread status to filter on.
4472
4519
  Must be one of 'idle', 'busy', 'interrupted' or 'error'.
4473
4520
  limit: Limit on number of threads to return.
@@ -4497,6 +4544,8 @@ class SyncThreadsClient:
4497
4544
  payload["metadata"] = metadata
4498
4545
  if values:
4499
4546
  payload["values"] = values
4547
+ if ids:
4548
+ payload["ids"] = ids
4500
4549
  if status:
4501
4550
  payload["status"] = status
4502
4551
  if sort_by:
File without changes
File without changes
File without changes
File without changes
File without changes