langgraph-api 0.2.95__py3-none-any.whl → 0.2.97__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 langgraph-api might be problematic. Click here for more details.

langgraph_api/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.95"
1
+ __version__ = "0.2.97"
@@ -39,11 +39,15 @@ async def create_thread(
39
39
  )
40
40
 
41
41
  if supersteps := payload.get("supersteps"):
42
- await Threads.State.bulk(
43
- conn,
44
- config={"configurable": {"thread_id": thread_id}},
45
- supersteps=supersteps,
46
- )
42
+ try:
43
+ await Threads.State.bulk(
44
+ conn,
45
+ config={"configurable": {"thread_id": thread_id}},
46
+ supersteps=supersteps,
47
+ )
48
+ except HTTPException as e:
49
+ detail = f"Thread {thread_id} was created, but there were problems updating the state: {e.detail}"
50
+ raise HTTPException(status_code=201, detail=detail) from e
47
51
 
48
52
  return ApiResponse(await fetchone(iter, not_found_code=409))
49
53
 
langgraph_api/asyncio.py CHANGED
@@ -141,6 +141,13 @@ def call_soon_in_main_loop(coro: Coroutine[Any, Any, T]) -> asyncio.Future[T]:
141
141
  return this_loop_fut
142
142
 
143
143
 
144
+ def call_soon_threadsafe(callback, *args) -> asyncio.Handle:
145
+ """Run a coroutine in the main event loop."""
146
+ if _MAIN_LOOP is None:
147
+ raise RuntimeError("No event loop set")
148
+ return _MAIN_LOOP.call_soon_threadsafe(callback, *args)
149
+
150
+
144
151
  class SimpleTaskGroup(AbstractAsyncContextManager["SimpleTaskGroup"]):
145
152
  """An async task group that can be configured to wait and/or cancel tasks on exit.
146
153
 
@@ -204,11 +204,11 @@ def get_header_patterns() -> tuple[
204
204
  configurable = config.HTTP_CONFIG.get("configurable_headers")
205
205
  if not configurable:
206
206
  return None, None
207
- header_includes = configurable.get("includes") or []
207
+ header_includes = configurable.get("includes") or configurable.get("include") or []
208
208
  include_patterns = []
209
209
  for include in header_includes:
210
210
  include_patterns.append(translate_pattern(include))
211
- header_excludes = configurable.get("excludes") or []
211
+ header_excludes = configurable.get("excludes") or configurable.get("exclude") or []
212
212
  exclude_patterns = []
213
213
  for exclude in header_excludes:
214
214
  exclude_patterns.append(translate_pattern(exclude))
langgraph_api/state.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import typing
4
4
 
5
- from langgraph.types import StateSnapshot
5
+ from langgraph.types import Interrupt, StateSnapshot
6
6
 
7
7
  from langgraph_api.schema import Checkpoint, ThreadState
8
8
 
@@ -38,6 +38,23 @@ def runnable_config_to_checkpoint(
38
38
  return checkpoint
39
39
 
40
40
 
41
+ def state_interrupt_to_thread_interrupt(interrupt: Interrupt | dict) -> dict:
42
+ # Sometimes the interrupt received in StateSnapshot is a dict.
43
+ # Let's convert it toan Interrupt object to gain access to dynamic `interrupt_id`.
44
+ if isinstance(interrupt, dict):
45
+ interrupt = Interrupt(**interrupt)
46
+
47
+ return {
48
+ "interrupt_id": interrupt.interrupt_id
49
+ if hasattr(interrupt, "interrupt_id")
50
+ else None,
51
+ "value": interrupt.value,
52
+ "resumable": interrupt.resumable,
53
+ "ns": interrupt.ns,
54
+ "when": interrupt.when,
55
+ }
56
+
57
+
41
58
  def state_snapshot_to_thread_state(state: StateSnapshot) -> ThreadState:
42
59
  return {
43
60
  "values": state.values,
@@ -48,7 +65,9 @@ def state_snapshot_to_thread_state(state: StateSnapshot) -> ThreadState:
48
65
  "name": t.name,
49
66
  "path": t.path,
50
67
  "error": t.error,
51
- "interrupts": t.interrupts,
68
+ "interrupts": [
69
+ state_interrupt_to_thread_interrupt(i) for i in t.interrupts
70
+ ],
52
71
  "checkpoint": t.state["configurable"]
53
72
  if t.state is not None and not isinstance(t.state, StateSnapshot)
54
73
  else None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-api
3
- Version: 0.2.95
3
+ Version: 0.2.97
4
4
  Author-email: Nuno Campos <nuno@langchain.dev>, Will Fu-Hinthorn <will@langchain.dev>
5
5
  License: Elastic-2.0
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
- langgraph_api/__init__.py,sha256=EHI7jWUI5UvuAnBQ8tm7j7Ud4Xzqu9b6iEixYwRIblc,23
1
+ langgraph_api/__init__.py,sha256=RAdKT_b9XyrNSz1oKKlaZI7EzGUu2fiSiM_9rJ8Pq3c,23
2
2
  langgraph_api/asgi_transport.py,sha256=eqifhHxNnxvI7jJqrY1_8RjL4Fp9NdN4prEub2FWBt8,5091
3
- langgraph_api/asyncio.py,sha256=qrYEqPRrqtGq7E7KjcMC-ALyN79HkRnmp9rM2TAw9L8,9404
3
+ langgraph_api/asyncio.py,sha256=Wv4Rwm-a-Cf6JpfgJmVuVlXQ7SlwrjbTn0eq1ux8I2Q,9652
4
4
  langgraph_api/cli.py,sha256=-R0fvxg4KNxTkSe7xvDZruF24UMhStJYjpAYlUx3PBk,16018
5
5
  langgraph_api/command.py,sha256=3O9v3i0OPa96ARyJ_oJbLXkfO8rPgDhLCswgO9koTFA,768
6
6
  langgraph_api/config.py,sha256=Nxhx6fOsxk_u-Aae54JAGn46JQ1wKXPjeu_KX_3d4wQ,11918
@@ -19,7 +19,7 @@ langgraph_api/schema.py,sha256=IdloGYognffSCZOFPujXE0QfNNlxQGd3BJbinYy5Q1c,5708
19
19
  langgraph_api/serde.py,sha256=0ALETUn582vNF-m0l_WOZGF_scL1VPA39fDkwMJQPrg,5187
20
20
  langgraph_api/server.py,sha256=Z_VL-kIphybTRDWBIqHMfRhgCmAFyTRqAGlgnHQF0Zg,6973
21
21
  langgraph_api/sse.py,sha256=SLdtZmTdh5D8fbWrQjuY9HYLd2dg8Rmi6ZMmFMVc2iE,4204
22
- langgraph_api/state.py,sha256=NLl5YgLKppHJ7zfF0bXjsroXmIGCZez0IlDAKNGVy0g,2365
22
+ langgraph_api/state.py,sha256=Fn38_E8K0LmK6x6RsZCWr-cnu8RH-2qLBXqkA3TgfdY,3045
23
23
  langgraph_api/store.py,sha256=srRI0fQXNFo_RSUs4apucr4BEp_KrIseJksZXs32MlQ,4635
24
24
  langgraph_api/stream.py,sha256=EorM9BD7oiCvkRXlMqnOkBd9P1X3mEagS_oHp-_9aRQ,13669
25
25
  langgraph_api/thread_ttl.py,sha256=-Ox8NFHqUH3wGNdEKMIfAXUubY5WGifIgCaJ7npqLgw,1762
@@ -35,7 +35,7 @@ langgraph_api/api/meta.py,sha256=fmc7btbtl5KVlU_vQ3Bj4J861IjlqmjBKNtnxSV-S-Q,419
35
35
  langgraph_api/api/openapi.py,sha256=KToI2glOEsvrhDpwdScdBnL9xoLOqkTxx5zKq2pMuKQ,11957
36
36
  langgraph_api/api/runs.py,sha256=37phCkg8pgEQZQNqFlehIHmvVbdeD8A1ojV7Vk7Mm08,19944
37
37
  langgraph_api/api/store.py,sha256=TSeMiuMfrifmEnEbL0aObC2DPeseLlmZvAMaMzPgG3Y,5535
38
- langgraph_api/api/threads.py,sha256=ogMKmEoiycuaV3fa5kpupDohJ7fwUOfVczt6-WSK4FE,9322
38
+ langgraph_api/api/threads.py,sha256=nQMlGnsrFD1F4S-ID_q0HZrF2GZ0Pm7aV04Sh1eYgds,9588
39
39
  langgraph_api/api/ui.py,sha256=17QrRy2XVzP7x_0RdRw7pmSv-n1lmnb54byHCGGeNhM,2490
40
40
  langgraph_api/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  langgraph_api/auth/custom.py,sha256=ZtNSQ4hIldbd2HvRsilwKzN_hjCWIiIOHClmYyPi8FM,22206
@@ -74,7 +74,7 @@ langgraph_api/middleware/http_logger.py,sha256=uroMCag49-uPHTt8K3glkl-0RnWL20YEg
74
74
  langgraph_api/middleware/private_network.py,sha256=eYgdyU8AzU2XJu362i1L8aSFoQRiV7_aLBPw7_EgeqI,2111
75
75
  langgraph_api/middleware/request_id.py,sha256=SDj3Yi3WvTbFQ2ewrPQBjAV8sYReOJGeIiuoHeZpR9g,1242
76
76
  langgraph_api/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
77
- langgraph_api/models/run.py,sha256=pIa26KUz6n1naxIJQtKSW7CghHJltSlkQhK9KDagEuQ,14552
77
+ langgraph_api/models/run.py,sha256=ZedBLmzeXFHbpYvNWJ50xhKakDnQwgZmeZBjNlMJqWA,14614
78
78
  langgraph_api/tunneling/cloudflare.py,sha256=iKb6tj-VWPlDchHFjuQyep2Dpb-w2NGfJKt-WJG9LH0,3650
79
79
  langgraph_api/utils/__init__.py,sha256=92mSti9GfGdMRRWyESKQW5yV-75Z9icGHnIrBYvdypU,3619
80
80
  langgraph_api/utils/cache.py,sha256=SrtIWYibbrNeZzLXLUGBFhJPkMVNQnVxR5giiYGHEfI,1810
@@ -94,8 +94,8 @@ langgraph_runtime/store.py,sha256=7mowndlsIroGHv3NpTSOZDJR0lCuaYMBoTnTrewjslw,11
94
94
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
95
95
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
96
96
  openapi.json,sha256=p5tn_cNRiFA0HN3L6JfC9Nm16Hgv-BxvAQcJymKhVWI,143296
97
- langgraph_api-0.2.95.dist-info/METADATA,sha256=gP3sm3xflctI93zu9c9D-Rgo_5xxlPte7cKXBK-1k-w,3891
98
- langgraph_api-0.2.95.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
99
- langgraph_api-0.2.95.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
100
- langgraph_api-0.2.95.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
101
- langgraph_api-0.2.95.dist-info/RECORD,,
97
+ langgraph_api-0.2.97.dist-info/METADATA,sha256=MRacU2D-_DeiYBazOk4Wp5CteYaN6TLLseVBq4AqUiA,3891
98
+ langgraph_api-0.2.97.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
99
+ langgraph_api-0.2.97.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
100
+ langgraph_api-0.2.97.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
101
+ langgraph_api-0.2.97.dist-info/RECORD,,