langgraph-api 0.2.61__py3-none-any.whl → 0.2.63__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.61"
1
+ __version__ = "0.2.63"
langgraph_api/api/meta.py CHANGED
@@ -48,31 +48,45 @@ async def meta_metrics(request: ApiRequest):
48
48
 
49
49
  if metrics_format == "json":
50
50
  async with connect() as conn:
51
- return JSONResponse(
52
- {
53
- **pool_stats(),
54
- "workers": worker_metrics,
55
- "queue": await Runs.stats(conn),
56
- }
57
- )
51
+ resp = {
52
+ **pool_stats(),
53
+ "queue": await Runs.stats(conn),
54
+ }
55
+ if config.N_JOBS_PER_WORKER > 0:
56
+ resp["workers"] = worker_metrics
57
+ return JSONResponse(resp)
58
58
  elif metrics_format == "prometheus":
59
59
  # LANGSMITH_HOST_PROJECT_ID and LANGSMITH_HOST_REVISION_ID are injected
60
60
  # into the deployed image by host-backend.
61
61
  project_id = os.getenv("LANGSMITH_HOST_PROJECT_ID")
62
62
  revision_id = os.getenv("LANGSMITH_HOST_REVISION_ID")
63
63
 
64
- metrics = [
65
- "# HELP lg_api_workers_max The maximum number of workers available.",
66
- "# TYPE lg_api_workers_max gauge",
67
- f'lg_api_workers_max{{project_id="{project_id}", revision_id="{revision_id}"}} {workers_max}',
68
- "# HELP lg_api_workers_active The number of currently active workers.",
69
- "# TYPE lg_api_workers_active gauge",
70
- f'lg_api_workers_active{{project_id="{project_id}", revision_id="{revision_id}"}} {workers_active}',
71
- "# HELP lg_api_workers_available The number of available (idle) workers.",
72
- "# TYPE lg_api_workers_available gauge",
73
- f'lg_api_workers_available{{project_id="{project_id}", revision_id="{revision_id}"}} {workers_available}',
74
- # In the future, we can add more metrics to be scraped by Prometheus.
75
- ]
64
+ async with connect() as conn:
65
+ queue_stats = await Runs.stats(conn)
66
+
67
+ metrics = [
68
+ "# HELP lg_api_num_pending_runs The number of runs currently pending.",
69
+ "# TYPE lg_api_num_pending_runs gauge",
70
+ f'lg_api_num_pending_runs{{project_id="{project_id}", revision_id="{revision_id}"}} {queue_stats["n_pending"]}',
71
+ "# HELP lg_api_num_running_runs The number of runs currently running.",
72
+ "# TYPE lg_api_num_running_runs gauge",
73
+ f'lg_api_num_running_runs{{project_id="{project_id}", revision_id="{revision_id}"}} {queue_stats["n_running"]}',
74
+ ]
75
+
76
+ if config.N_JOBS_PER_WORKER > 0:
77
+ metrics.extend(
78
+ [
79
+ "# HELP lg_api_workers_max The maximum number of workers available.",
80
+ "# TYPE lg_api_workers_max gauge",
81
+ f'lg_api_workers_max{{project_id="{project_id}", revision_id="{revision_id}"}} {workers_max}',
82
+ "# HELP lg_api_workers_active The number of currently active workers.",
83
+ "# TYPE lg_api_workers_active gauge",
84
+ f'lg_api_workers_active{{project_id="{project_id}", revision_id="{revision_id}"}} {workers_active}',
85
+ "# HELP lg_api_workers_available The number of available (idle) workers.",
86
+ "# TYPE lg_api_workers_available gauge",
87
+ f'lg_api_workers_available{{project_id="{project_id}", revision_id="{revision_id}"}} {workers_available}',
88
+ ]
89
+ )
76
90
 
77
91
  metrics_response = "\n".join(metrics)
78
92
  return PlainTextResponse(metrics_response)
@@ -4,3 +4,12 @@ from starlette.authentication import BaseUser
4
4
 
5
5
  class StudioUser(StudioUserBase, BaseUser):
6
6
  """StudioUser class."""
7
+
8
+ def dict(self):
9
+ return {
10
+ "kind": "StudioUser",
11
+ "is_authenticated": self.is_authenticated,
12
+ "display_name": self.display_name,
13
+ "identity": self.identity,
14
+ "permissions": self.permissions,
15
+ }
@@ -858,6 +858,16 @@ async def handle_js_auth_event(
858
858
  ctx: Auth.types.AuthContext | None,
859
859
  value: dict,
860
860
  ) -> Auth.types.FilterType | None:
861
+ if hasattr(ctx.user, "dict") and callable(ctx.user.dict):
862
+ user = ctx.user.dict()
863
+ else:
864
+ user = {
865
+ "is_authenticated": ctx.user.is_authenticated,
866
+ "display_name": ctx.user.display_name,
867
+ "identity": ctx.user.identity,
868
+ "permissions": ctx.user.permissions,
869
+ }
870
+
861
871
  res = await _client.post(
862
872
  "/auth/authorize",
863
873
  headers={"Content-Type": "application/json"},
@@ -868,7 +878,7 @@ async def handle_js_auth_event(
868
878
  "value": value,
869
879
  "context": (
870
880
  {
871
- "user": cast(DotDict, ctx.user).dict(),
881
+ "user": user,
872
882
  "scopes": ctx.permissions,
873
883
  }
874
884
  if ctx
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-api
3
- Version: 0.2.61
3
+ Version: 0.2.63
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,4 +1,4 @@
1
- langgraph_api/__init__.py,sha256=kZgWAIergNf5V9AKR_m5_2OkmHm70EJlB00_haCLeZY,23
1
+ langgraph_api/__init__.py,sha256=-1334OOo2G37F3JuThu8EjP57zqXv1siHIJbHDgWfTE,23
2
2
  langgraph_api/asgi_transport.py,sha256=eqifhHxNnxvI7jJqrY1_8RjL4Fp9NdN4prEub2FWBt8,5091
3
3
  langgraph_api/asyncio.py,sha256=Odnc6mAJIGF3eFWT8Xcrg2Zam7FwzXkfCWEHaXfrzQQ,9371
4
4
  langgraph_api/cli.py,sha256=9Ou3tGDDY_VVLt5DFle8UviJdpI4ZigC5hElYvq2-To,14519
@@ -28,7 +28,7 @@ langgraph_api/worker.py,sha256=uQg_YEmr0zDTX3BR3bcI2L6SWu4YRWbgELk0gvlnymc,15900
28
28
  langgraph_api/api/__init__.py,sha256=YVzpbn5IQotvuuLG9fhS9QMrxXfP4s4EpEMG0n4q3Nw,5625
29
29
  langgraph_api/api/assistants.py,sha256=6IPVKQBlI95-Z4nYdqBY9st9oynGJAocL67cwnDaZCk,15744
30
30
  langgraph_api/api/mcp.py,sha256=RvRYgANqRzNQzSmgjNkq4RlKTtoEJYil04ot9lsmEtE,14352
31
- langgraph_api/api/meta.py,sha256=Yvb6yAqmZy4Nmk8JaNLUcUXA9irlankqS6XhXtXLWG0,3087
31
+ langgraph_api/api/meta.py,sha256=MU9Ehdo2M8oaxGVBXVQFNRP6qSTXyrsGXFcndRlnvIE,3924
32
32
  langgraph_api/api/openapi.py,sha256=362m6Ny8wOwZ6HrDK9JAVUzPkyLYWKeV1E71hPOaA0U,11278
33
33
  langgraph_api/api/runs.py,sha256=9jU9C4myBhgZXyvR9MzNn9KrpNo7DvWbg8uNeWzSmKE,19524
34
34
  langgraph_api/api/store.py,sha256=TSeMiuMfrifmEnEbL0aObC2DPeseLlmZvAMaMzPgG3Y,5535
@@ -38,7 +38,7 @@ langgraph_api/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
38
38
  langgraph_api/auth/custom.py,sha256=f_gKqtz1BlPQcwDBlG91k78nxAWKLcxU3wF1tvbZByg,22120
39
39
  langgraph_api/auth/middleware.py,sha256=jDA4t41DUoAArEY_PNoXesIUBJ0nGhh85QzRdn5EPD0,1916
40
40
  langgraph_api/auth/noop.py,sha256=Bk6Nf3p8D_iMVy_OyfPlyiJp_aEwzL-sHrbxoXpCbac,586
41
- langgraph_api/auth/studio_user.py,sha256=FzFQRROKDlA9JjtBuwyZvk6Mbwno5M9RVYjDO6FU3F8,186
41
+ langgraph_api/auth/studio_user.py,sha256=fojJpexdIZYI1w3awiqOLSwMUiK_M_3p4mlfQI0o-BE,454
42
42
  langgraph_api/auth/langsmith/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
43
  langgraph_api/auth/langsmith/backend.py,sha256=UNsXa1rXuUJy8fdnasdILIWoxWIlHafY03YJChV0USk,2764
44
44
  langgraph_api/auth/langsmith/client.py,sha256=eKchvAom7hdkUXauD8vHNceBDDUijrFgdTV8bKd7x4Q,3998
@@ -52,7 +52,7 @@ langgraph_api/js/client.mts,sha256=N9CTH7mbXGSD-gpv-XyruYsHI-rgrObL8cQoAp5s3_U,3
52
52
  langgraph_api/js/errors.py,sha256=Cm1TKWlUCwZReDC5AQ6SgNIVGD27Qov2xcgHyf8-GXo,361
53
53
  langgraph_api/js/global.d.ts,sha256=j4GhgtQSZ5_cHzjSPcHgMJ8tfBThxrH-pUOrrJGteOU,196
54
54
  langgraph_api/js/package.json,sha256=BpNAO88mbE-Gv4WzQfj1TLktCWGqm6XBqI892ObuOUw,1333
55
- langgraph_api/js/remote.py,sha256=TwEpmUm6bTLnH8Ku4zCP3cCHyNrYJMIFs4TRUHQTI8Y,35796
55
+ langgraph_api/js/remote.py,sha256=WlfVJbxsk-T8EzzGGnzpZbZmMfh_NfVYTNvU663j1oA,36103
56
56
  langgraph_api/js/schema.py,sha256=7idnv7URlYUdSNMBXQcw7E4SxaPxCq_Oxwnlml8q5ik,408
57
57
  langgraph_api/js/sse.py,sha256=lsfp4nyJyA1COmlKG9e2gJnTttf_HGCB5wyH8OZBER8,4105
58
58
  langgraph_api/js/tsconfig.json,sha256=imCYqVnqFpaBoZPx8k1nO4slHIWBFsSlmCYhO73cpBs,341
@@ -86,8 +86,8 @@ langgraph_runtime/store.py,sha256=7mowndlsIroGHv3NpTSOZDJR0lCuaYMBoTnTrewjslw,11
86
86
  LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
87
87
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
88
88
  openapi.json,sha256=wrJup7sCRlZXTRagjzGZ7474U1wma4ZzYTkkninrT6M,141875
89
- langgraph_api-0.2.61.dist-info/METADATA,sha256=XdQqNTkMVvTLc8e34erKFgs0GU97seInvZNgWDAxxZU,3891
90
- langgraph_api-0.2.61.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
91
- langgraph_api-0.2.61.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
92
- langgraph_api-0.2.61.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
93
- langgraph_api-0.2.61.dist-info/RECORD,,
89
+ langgraph_api-0.2.63.dist-info/METADATA,sha256=Vyve0lsW126fu-IGqUx4U_mKHDdauRHMh1cezNHa_I0,3891
90
+ langgraph_api-0.2.63.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
91
+ langgraph_api-0.2.63.dist-info/entry_points.txt,sha256=hGedv8n7cgi41PypMfinwS_HfCwA7xJIfS0jAp8htV8,78
92
+ langgraph_api-0.2.63.dist-info/licenses/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
93
+ langgraph_api-0.2.63.dist-info/RECORD,,