langgraph-api 0.2.11__py3-none-any.whl → 0.2.12__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.11"
1
+ __version__ = "0.2.12"
langgraph_api/api/runs.py CHANGED
@@ -285,7 +285,7 @@ async def wait_run_stateless(request: ApiRequest):
285
285
 
286
286
 
287
287
  @retry_db
288
- async def list_runs_http(
288
+ async def list_runs(
289
289
  request: ApiRequest,
290
290
  ):
291
291
  """List all runs for a thread."""
@@ -312,7 +312,7 @@ async def list_runs_http(
312
312
 
313
313
 
314
314
  @retry_db
315
- async def get_run_http(request: ApiRequest):
315
+ async def get_run(request: ApiRequest):
316
316
  """Get a run by ID."""
317
317
  thread_id = request.path_params["thread_id"]
318
318
  run_id = request.path_params["run_id"]
@@ -349,7 +349,7 @@ async def join_run(request: ApiRequest):
349
349
 
350
350
 
351
351
  @retry_db
352
- async def join_run_stream_endpoint(request: ApiRequest):
352
+ async def join_run_stream(request: ApiRequest):
353
353
  """Wait for a run to finish."""
354
354
  thread_id = request.path_params["thread_id"]
355
355
  run_id = request.path_params["run_id"]
@@ -541,11 +541,11 @@ runs_routes = [
541
541
  ApiRoute("/threads/{thread_id}/runs/{run_id}/join", join_run, methods=["GET"]),
542
542
  ApiRoute(
543
543
  "/threads/{thread_id}/runs/{run_id}/stream",
544
- join_run_stream_endpoint,
544
+ join_run_stream,
545
545
  methods=["GET"],
546
546
  ),
547
547
  ApiRoute("/threads/{thread_id}/runs/{run_id}/cancel", cancel_run, methods=["POST"]),
548
- ApiRoute("/threads/{thread_id}/runs/{run_id}", get_run_http, methods=["GET"]),
548
+ ApiRoute("/threads/{thread_id}/runs/{run_id}", get_run, methods=["GET"]),
549
549
  ApiRoute("/threads/{thread_id}/runs/{run_id}", delete_run, methods=["DELETE"]),
550
550
  ApiRoute("/threads/{thread_id}/runs/stream", stream_run, methods=["POST"]),
551
551
  ApiRoute("/threads/{thread_id}/runs/wait", wait_run, methods=["POST"]),
@@ -557,7 +557,7 @@ runs_routes = [
557
557
  if config.FF_CRONS_ENABLED and plus_features_enabled()
558
558
  else None
559
559
  ),
560
- ApiRoute("/threads/{thread_id}/runs", list_runs_http, methods=["GET"]),
560
+ ApiRoute("/threads/{thread_id}/runs", list_runs, methods=["GET"]),
561
561
  (
562
562
  ApiRoute("/runs/crons/{cron_id}", delete_cron, methods=["DELETE"])
563
563
  if config.FF_CRONS_ENABLED and plus_features_enabled()
langgraph_api/config.py CHANGED
@@ -148,6 +148,8 @@ STATS_INTERVAL_SECS = env("STATS_INTERVAL_SECS", cast=int, default=60)
148
148
  DATABASE_URI = env("DATABASE_URI", cast=str, default=getenv("POSTGRES_URI", undefined))
149
149
  MIGRATIONS_PATH = env("MIGRATIONS_PATH", cast=str, default="/storage/migrations")
150
150
 
151
+ POSTGRES_POOL_MAX_SIZE = env("LANGGRAPH_POSTGRES_POOL_MAX_SIZE", cast=int, default=150)
152
+
151
153
 
152
154
  def _get_encryption_key(key_str: str | None):
153
155
  if not key_str:
langgraph_api/route.py CHANGED
@@ -9,16 +9,25 @@ from starlette._utils import is_async_callable
9
9
  from starlette.concurrency import run_in_threadpool
10
10
  from starlette.middleware import Middleware
11
11
  from starlette.requests import Request
12
- from starlette.responses import JSONResponse, Response
12
+ from starlette.responses import JSONResponse
13
13
  from starlette.routing import Route, compile_path, get_name
14
14
  from starlette.types import ASGIApp, Receive, Scope, Send
15
15
 
16
16
  from langgraph_api.serde import json_dumpb
17
17
  from langgraph_api.utils import get_auth_ctx, with_user
18
18
 
19
+ SchemaType = (
20
+ jsonschema_rs.Draft4Validator
21
+ | jsonschema_rs.Draft6Validator
22
+ | jsonschema_rs.Draft7Validator
23
+ | jsonschema_rs.Draft201909Validator
24
+ | jsonschema_rs.Draft202012Validator
25
+ | None
26
+ )
27
+
19
28
 
20
29
  def api_request_response(
21
- func: typing.Callable[[Request], typing.Awaitable[Response] | Response],
30
+ func: typing.Callable[[Request], typing.Awaitable[ASGIApp] | ASGIApp],
22
31
  ) -> ASGIApp:
23
32
  """
24
33
  Takes a function or coroutine `func(request) -> response`,
@@ -30,9 +39,11 @@ def api_request_response(
30
39
 
31
40
  async def app(scope: Scope, receive: Receive, send: Send) -> None:
32
41
  if is_async_callable(func):
33
- response = await func(request)
42
+ response: ASGIApp = await func(request)
34
43
  else:
35
- response = await run_in_threadpool(func, request)
44
+ response = await run_in_threadpool(
45
+ typing.cast(typing.Callable[[Request], ASGIApp], func), request
46
+ )
36
47
  await response(scope, receive, send)
37
48
 
38
49
  await wrap_app_handling_exceptions(app, request)(scope, receive, send)
@@ -45,9 +56,7 @@ class ApiResponse(JSONResponse):
45
56
  return json_dumpb(content)
46
57
 
47
58
 
48
- def _json_loads(
49
- content: bytearray, schema: jsonschema_rs.Draft4Validator | None
50
- ) -> typing.Any:
59
+ def _json_loads(content: bytearray, schema: SchemaType) -> typing.Any:
51
60
  json = orjson.loads(content)
52
61
  if schema is not None:
53
62
  schema.validate(json)
@@ -55,7 +64,7 @@ def _json_loads(
55
64
 
56
65
 
57
66
  class ApiRequest(Request):
58
- async def body(self) -> typing.Coroutine[typing.Any, typing.Any, bytearray]:
67
+ async def body(self) -> bytearray:
59
68
  if not hasattr(self, "_body"):
60
69
  chunks = bytearray()
61
70
  async for chunk in self.stream():
@@ -63,7 +72,7 @@ class ApiRequest(Request):
63
72
  self._body = chunks
64
73
  return self._body
65
74
 
66
- async def json(self, schema: jsonschema_rs.Draft4Validator | None) -> typing.Any:
75
+ async def json(self, schema: SchemaType = None) -> typing.Any:
67
76
  if not hasattr(self, "_json"):
68
77
  body = await self.body()
69
78
  self._json = await run_in_threadpool(_json_loads, body, schema)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langgraph-api
3
- Version: 0.2.11
3
+ Version: 0.2.12
4
4
  Summary:
5
5
  License: Elastic-2.0
6
6
  Author: Nuno Campos
@@ -1,11 +1,11 @@
1
1
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
2
- langgraph_api/__init__.py,sha256=_MLx4ac1juJPWEEiC9kMQISX3x3jFBr507jM2P_hxMg,23
2
+ langgraph_api/__init__.py,sha256=X4KG3FscE5AhbGbcdDDgdDC550CVpxNMwdNLcx6EQ7M,23
3
3
  langgraph_api/api/__init__.py,sha256=YVzpbn5IQotvuuLG9fhS9QMrxXfP4s4EpEMG0n4q3Nw,5625
4
4
  langgraph_api/api/assistants.py,sha256=mcKaVeNG8hQAV4IQDhaukS7FgVqTIVQNTyti3GfK2KI,14649
5
5
  langgraph_api/api/mcp.py,sha256=RvRYgANqRzNQzSmgjNkq4RlKTtoEJYil04ot9lsmEtE,14352
6
6
  langgraph_api/api/meta.py,sha256=sTgkhE-DaFWpERG6F7KelZfDsmJAiVc4j5dg50tDkSo,2950
7
7
  langgraph_api/api/openapi.py,sha256=WYpkjwsVV056qBkBVbGjhh-TfU9-IgZMY2au1s1PhZ4,15953
8
- langgraph_api/api/runs.py,sha256=dhHZ3xu7V0anftqzXaOYnhVEryJpVeqzu60MFiUw4u8,18010
8
+ langgraph_api/api/runs.py,sha256=ys8X3g2EGbuF_OF1htM4jcLu4Mqztd8v7ttosmIbdsw,17972
9
9
  langgraph_api/api/store.py,sha256=G4Fm8hgFLlJUW5_ekLS_IOgCfpFy-TK9uq5r9QTOELQ,5447
10
10
  langgraph_api/api/threads.py,sha256=ogMKmEoiycuaV3fa5kpupDohJ7fwUOfVczt6-WSK4FE,9322
11
11
  langgraph_api/api/ui.py,sha256=2nlipYV2nUGR4T9pceaAbgN1lS3-T2zPBh7Nv3j9eZQ,2479
@@ -20,7 +20,7 @@ langgraph_api/auth/noop.py,sha256=Bk6Nf3p8D_iMVy_OyfPlyiJp_aEwzL-sHrbxoXpCbac,58
20
20
  langgraph_api/auth/studio_user.py,sha256=FzFQRROKDlA9JjtBuwyZvk6Mbwno5M9RVYjDO6FU3F8,186
21
21
  langgraph_api/cli.py,sha256=9Ou3tGDDY_VVLt5DFle8UviJdpI4ZigC5hElYvq2-To,14519
22
22
  langgraph_api/command.py,sha256=3O9v3i0OPa96ARyJ_oJbLXkfO8rPgDhLCswgO9koTFA,768
23
- langgraph_api/config.py,sha256=KXQ3W0LzGuEqc0kfB2B37tvqFBwl66rW7vXtw1gIZGc,10773
23
+ langgraph_api/config.py,sha256=Jsv1Qw1esmO1hllo2_0UhDtcIxOAmF38-8xutpxDcw4,10862
24
24
  langgraph_api/cron_scheduler.py,sha256=i87j4pJrcsmsqMKeKUs69gaAjrGaSM3pM3jnXdN5JDQ,2630
25
25
  langgraph_api/errors.py,sha256=Bu_i5drgNTyJcLiyrwVE_6-XrSU50BHf9TDpttki9wQ,1690
26
26
  langgraph_api/graph.py,sha256=YyWCPtoI9VDV0knjCMUFoH4r9OFVsAiv5K8FzbziMqs,21488
@@ -78,7 +78,7 @@ langgraph_api/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
78
78
  langgraph_api/models/run.py,sha256=hPiiP6jgJX-jsg4Aihwi0tpC-nkTabV9YE0WNlD4EjI,13166
79
79
  langgraph_api/patch.py,sha256=Dgs0PXHytekX4SUL6KsjjN0hHcOtGLvv1GRGbh6PswU,1408
80
80
  langgraph_api/queue_entrypoint.py,sha256=gjtajZfnDXhsi7JElfmkY-p0ENBiKBDJ4Ugiw-exapw,1839
81
- langgraph_api/route.py,sha256=fM4qYCGbmH0a3_cV8uKocb1sLklehxO6HhdRXqLK6OM,4421
81
+ langgraph_api/route.py,sha256=uN311KjIugyNHG3rmVw_ms61QO1W1l16jJx03rf0R_s,4630
82
82
  langgraph_api/schema.py,sha256=2711t4PIBk5dky4gmMndrTRC9CVvAgH47C9FKDxhkBo,5444
83
83
  langgraph_api/serde.py,sha256=TVsx2QQtepf8Wsgsabcku1NV4Vbugu4Oujmdnq4qMS0,3964
84
84
  langgraph_api/server.py,sha256=lCv_ZHLbMnhKRhdaSJi1edk-O9We-MnQafkGzdWlngw,6599
@@ -96,8 +96,8 @@ langgraph_license/validation.py,sha256=ZKraAVJArAABKqrmHN-EN18ncoNUmRm500Yt1Sc7t
96
96
  langgraph_runtime/__init__.py,sha256=O4GgSmu33c-Pr8Xzxj_brcK5vkm70iNTcyxEjICFZxA,1075
97
97
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
98
98
  openapi.json,sha256=GefWJwBrbrN_jNDAEFlwNEXx1ottRtvjOmKBi965KLU,133756
99
- langgraph_api-0.2.11.dist-info/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
100
- langgraph_api-0.2.11.dist-info/METADATA,sha256=Viok-PPckUyL3Gq-DZo_zpO5yCDkdN8bC97j8ZGPvQg,4241
101
- langgraph_api-0.2.11.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
102
- langgraph_api-0.2.11.dist-info/entry_points.txt,sha256=3EYLgj89DfzqJHHYGxPH4A_fEtClvlRbWRUHaXO7hj4,77
103
- langgraph_api-0.2.11.dist-info/RECORD,,
99
+ langgraph_api-0.2.12.dist-info/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
100
+ langgraph_api-0.2.12.dist-info/METADATA,sha256=Eu9KpsvHFh84m1dIz0C5-QjU5B_IdKHOgpqPV691TqM,4241
101
+ langgraph_api-0.2.12.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
102
+ langgraph_api-0.2.12.dist-info/entry_points.txt,sha256=3EYLgj89DfzqJHHYGxPH4A_fEtClvlRbWRUHaXO7hj4,77
103
+ langgraph_api-0.2.12.dist-info/RECORD,,