langgraph-api 0.20.0.dev2__py3-none-any.whl → 0.20.0.dev4__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.
- langgraph_api/__init__.py +1 -1
- langgraph_api/_checkpointer/_adapter.py +5 -4
- langgraph_api/api/__init__.py +4 -7
- langgraph_api/api/assistants.py +2 -9
- langgraph_api/api/event_streaming.py +1 -5
- langgraph_api/api/mcp/_call_thread.py +1 -1
- langgraph_api/api/meta.py +5 -10
- langgraph_api/api/runs.py +8 -20
- langgraph_api/api/store.py +1 -1
- langgraph_api/api/threads.py +9 -24
- langgraph_api/cache.py +2 -15
- langgraph_api/cli.py +2 -11
- langgraph_api/cron_scheduler.py +2 -23
- langgraph_api/encryption/middleware.py +1 -66
- langgraph_api/errors.py +1 -2
- langgraph_api/event_streaming/state_normalizers.py +4 -0
- langgraph_api/feature_flags.py +8 -9
- langgraph_api/graph.py +3 -133
- langgraph_api/grpc/ops/runs.py +14 -2
- langgraph_api/grpc/ops/threads.py +2 -3
- langgraph_api/js/package.json +10 -10
- langgraph_api/js/remote.py +3 -3
- langgraph_api/js/yarn.lock +214 -168
- langgraph_api/metrics_collector.py +15 -25
- langgraph_api/metrics_otlp.py +2 -2
- langgraph_api/models/run.py +1 -6
- langgraph_api/operator_routes.py +1 -6
- langgraph_api/queue_entrypoint.py +2 -2
- langgraph_api/runtime/encryption.py +11 -149
- langgraph_api/runtime/lifespan.py +2 -2
- langgraph_api/runtime/store.py +134 -2
- langgraph_api/self_hosted_metrics.py +2 -8
- langgraph_api/server.py +1 -1
- langgraph_api/store.py +47 -22
- langgraph_api/stream.py +14 -22
- langgraph_api/transcript/__init__.py +0 -0
- langgraph_api/transcript/input_ids.py +100 -0
- langgraph_api/worker.py +1 -6
- langgraph_api/worker_runtime.py +5 -16
- {langgraph_api-0.20.0.dev2.dist-info → langgraph_api-0.20.0.dev4.dist-info}/METADATA +3 -3
- {langgraph_api-0.20.0.dev2.dist-info → langgraph_api-0.20.0.dev4.dist-info}/RECORD +53 -56
- langgraph_grpc_common/proto/core_api_pb2.py +178 -174
- langgraph_grpc_common/proto/core_api_pb2.pyi +101 -6
- langgraph_runtime/__init__.py +27 -55
- langgraph_runtime/checkpoint.py +5 -1
- langgraph_runtime/database.py +5 -1
- langgraph_runtime/encryption.py +6 -13
- langgraph_runtime/routes.py +6 -9
- langgraph_runtime/store.py +5 -1
- openapi.json +59 -0
- langgraph_runtime/lifespan.py +0 -4
- langgraph_runtime/metrics.py +0 -4
- langgraph_runtime/ops.py +0 -4
- langgraph_runtime/queue.py +0 -4
- langgraph_runtime/retry.py +0 -4
- {langgraph_api-0.20.0.dev2.dist-info → langgraph_api-0.20.0.dev4.dist-info}/WHEEL +0 -0
- {langgraph_api-0.20.0.dev2.dist-info → langgraph_api-0.20.0.dev4.dist-info}/entry_points.txt +0 -0
- {langgraph_api-0.20.0.dev2.dist-info → langgraph_api-0.20.0.dev4.dist-info}/licenses/LICENSE +0 -0
langgraph_api/graph.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
import functools
|
|
3
2
|
import glob
|
|
4
3
|
import importlib.util
|
|
5
4
|
import inspect
|
|
@@ -7,7 +6,6 @@ import logging
|
|
|
7
6
|
import os
|
|
8
7
|
import sys
|
|
9
8
|
import time
|
|
10
|
-
import warnings
|
|
11
9
|
from collections.abc import AsyncIterator, Callable, Generator
|
|
12
10
|
from contextlib import asynccontextmanager, contextmanager
|
|
13
11
|
from itertools import filterfalse
|
|
@@ -16,7 +14,6 @@ from uuid import UUID, uuid5
|
|
|
16
14
|
|
|
17
15
|
import orjson
|
|
18
16
|
import structlog
|
|
19
|
-
from langchain_core.embeddings import Embeddings # noqa: TC002
|
|
20
17
|
from langgraph.checkpoint.base import BaseCheckpointSaver
|
|
21
18
|
from langgraph.constants import CONFIG_KEY_CHECKPOINTER
|
|
22
19
|
from langgraph.graph import StateGraph
|
|
@@ -36,15 +33,16 @@ from langgraph_api._factory_utils import (
|
|
|
36
33
|
)
|
|
37
34
|
from langgraph_api.asyncio import as_asynccontextmanager
|
|
38
35
|
from langgraph_api.feature_flags import (
|
|
39
|
-
IS_POSTGRES_OR_GRPC_BACKEND,
|
|
40
36
|
USE_RUNTIME_CONTEXT_API,
|
|
41
37
|
)
|
|
42
38
|
from langgraph_api.js.base import BaseRemotePregel, is_js_path
|
|
39
|
+
from langgraph_api.runtime.retry import retry_db
|
|
43
40
|
from langgraph_api.schema import Config
|
|
44
41
|
from langgraph_api.timing import profiled_import
|
|
45
42
|
from langgraph_api.timing.startup import set_phase
|
|
46
43
|
from langgraph_api.utils.config import run_in_executor, var_child_runnable_config
|
|
47
44
|
from langgraph_api.utils.errors import GraphLoadError
|
|
45
|
+
from langgraph_runtime.database import connect
|
|
48
46
|
|
|
49
47
|
logger = structlog.stdlib.get_logger(__name__)
|
|
50
48
|
|
|
@@ -80,12 +78,7 @@ async def register_graph(
|
|
|
80
78
|
description: str | None = None,
|
|
81
79
|
) -> None:
|
|
82
80
|
"""Register a graph."""
|
|
83
|
-
from
|
|
84
|
-
|
|
85
|
-
if IS_POSTGRES_OR_GRPC_BACKEND:
|
|
86
|
-
from langgraph_api.grpc.ops import Assistants # noqa: PLC0415
|
|
87
|
-
else:
|
|
88
|
-
from langgraph_runtime.ops import Assistants # noqa: PLC0415
|
|
81
|
+
from langgraph_api.grpc.ops import Assistants # noqa: PLC0415
|
|
89
82
|
|
|
90
83
|
GRAPHS[graph_id] = graph
|
|
91
84
|
assistant_id = uuid5(NAMESPACE_GRAPH, graph_id)
|
|
@@ -93,8 +86,6 @@ async def register_graph(
|
|
|
93
86
|
if callable(graph):
|
|
94
87
|
classify_factory(graph, graph_id)
|
|
95
88
|
|
|
96
|
-
from langgraph_runtime.retry import retry_db # noqa: PLC0415
|
|
97
|
-
|
|
98
89
|
@retry_db
|
|
99
90
|
async def register_graph_db():
|
|
100
91
|
async with connect() as conn:
|
|
@@ -962,124 +953,3 @@ def _register_stream_transformers_from_module(graph_id: str, module: Any) -> Non
|
|
|
962
953
|
)
|
|
963
954
|
return
|
|
964
955
|
GRAPH_STREAM_TRANSFORMERS[graph_id] = factory
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
@functools.lru_cache(maxsize=1)
|
|
968
|
-
def _get_init_embeddings() -> Callable[[str, ...], "Embeddings"] | None:
|
|
969
|
-
try:
|
|
970
|
-
from langchain.embeddings import ( # noqa: PLC0415 # ty: ignore[unresolved-import]
|
|
971
|
-
init_embeddings,
|
|
972
|
-
)
|
|
973
|
-
|
|
974
|
-
return init_embeddings
|
|
975
|
-
except ImportError:
|
|
976
|
-
return None
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
@timing.timer(
|
|
980
|
-
message="Loading embeddings {embeddings_path}",
|
|
981
|
-
metadata_fn=lambda index_config: {"embeddings_path": index_config.get("embed")},
|
|
982
|
-
warn_threshold_secs=5,
|
|
983
|
-
warn_message="Loading embeddings '{embeddings_path}' took longer than expected",
|
|
984
|
-
error_threshold_secs=10,
|
|
985
|
-
)
|
|
986
|
-
def resolve_embeddings(index_config: dict) -> "Embeddings":
|
|
987
|
-
"""Return embeddings from config.
|
|
988
|
-
|
|
989
|
-
Args:
|
|
990
|
-
index_config: Configuration for the vector store index
|
|
991
|
-
Must contain an "embed" key specifying either:
|
|
992
|
-
- A path to a Python file and function (e.g. "./embeddings.py:get_embeddings")
|
|
993
|
-
- A LangChain embeddings identifier (e.g. "openai:text-embedding-3-small")
|
|
994
|
-
|
|
995
|
-
Returns:
|
|
996
|
-
Embeddings: A LangChain embeddings instance
|
|
997
|
-
|
|
998
|
-
Raises:
|
|
999
|
-
ValueError: If embeddings cannot be loaded from the config
|
|
1000
|
-
"""
|
|
1001
|
-
from langchain_core.embeddings import Embeddings # noqa: PLC0415
|
|
1002
|
-
from langgraph.store.base import ensure_embeddings # noqa: PLC0415
|
|
1003
|
-
|
|
1004
|
-
embed = index_config["embed"]
|
|
1005
|
-
if isinstance(embed, Embeddings):
|
|
1006
|
-
return embed
|
|
1007
|
-
if callable(embed):
|
|
1008
|
-
return ensure_embeddings(embed)
|
|
1009
|
-
if not isinstance(embed, str):
|
|
1010
|
-
raise ValueError(
|
|
1011
|
-
f"Embeddings config must be a string or callable, got: {type(embed).__name__}"
|
|
1012
|
-
)
|
|
1013
|
-
if ".py:" in embed:
|
|
1014
|
-
module_name, function = embed.rsplit(":", 1)
|
|
1015
|
-
module_name = module_name.rstrip(":")
|
|
1016
|
-
|
|
1017
|
-
try:
|
|
1018
|
-
with profiled_import(embed):
|
|
1019
|
-
if "/" in module_name:
|
|
1020
|
-
# Load from file path
|
|
1021
|
-
modname = (
|
|
1022
|
-
module_name.replace("/", "__")
|
|
1023
|
-
.replace(".py", "")
|
|
1024
|
-
.replace(" ", "_")
|
|
1025
|
-
)
|
|
1026
|
-
modspec = importlib.util.spec_from_file_location(
|
|
1027
|
-
modname, module_name
|
|
1028
|
-
)
|
|
1029
|
-
if modspec is None:
|
|
1030
|
-
raise ValueError(
|
|
1031
|
-
f"Could not find embeddings file: {module_name}"
|
|
1032
|
-
)
|
|
1033
|
-
module = importlib.util.module_from_spec(modspec)
|
|
1034
|
-
sys.modules[modname] = module
|
|
1035
|
-
modspec.loader.exec_module(module)
|
|
1036
|
-
else:
|
|
1037
|
-
# Load from Python module
|
|
1038
|
-
module = importlib.import_module(module_name)
|
|
1039
|
-
|
|
1040
|
-
embedding_fn = getattr(module, function, None)
|
|
1041
|
-
if embedding_fn is None:
|
|
1042
|
-
raise ValueError(
|
|
1043
|
-
f"Could not find embeddings function '{function}' in module: {module_name}"
|
|
1044
|
-
)
|
|
1045
|
-
|
|
1046
|
-
if isinstance(embedding_fn, Embeddings):
|
|
1047
|
-
return embedding_fn
|
|
1048
|
-
elif not callable(embedding_fn):
|
|
1049
|
-
raise ValueError(
|
|
1050
|
-
f"Embeddings function '{function}' in module: {module_name} is not callable"
|
|
1051
|
-
)
|
|
1052
|
-
|
|
1053
|
-
return ensure_embeddings(embedding_fn)
|
|
1054
|
-
|
|
1055
|
-
except ImportError as e:
|
|
1056
|
-
e.add_note(f"Could not import embeddings module:\n{module_name}\n\n")
|
|
1057
|
-
if lg_api_config.API_VARIANT == "local_dev":
|
|
1058
|
-
e.add_note(
|
|
1059
|
-
"If you're in development mode, make sure you've installed your project "
|
|
1060
|
-
"and its dependencies:\n"
|
|
1061
|
-
"- For requirements.txt: pip install -r requirements.txt\n"
|
|
1062
|
-
"- For pyproject.toml: pip install -e .\n"
|
|
1063
|
-
)
|
|
1064
|
-
raise
|
|
1065
|
-
except FileNotFoundError as e:
|
|
1066
|
-
raise ValueError(f"Could not find embeddings file: {module_name}") from e
|
|
1067
|
-
|
|
1068
|
-
else:
|
|
1069
|
-
# Load from LangChain embeddings
|
|
1070
|
-
init_embeddings = _get_init_embeddings()
|
|
1071
|
-
if init_embeddings is None:
|
|
1072
|
-
raise ValueError(
|
|
1073
|
-
f"Could not load LangChain embeddings '{embed}'. "
|
|
1074
|
-
"Loading embeddings by provider:identifier requires the langchain package (>=0.3.9). "
|
|
1075
|
-
"Install it with: pip install 'langchain>=0.3.9'"
|
|
1076
|
-
" or specify 'embed' as a path to a "
|
|
1077
|
-
"variable in a Python file instead."
|
|
1078
|
-
)
|
|
1079
|
-
# Capture warnings
|
|
1080
|
-
with warnings.catch_warnings():
|
|
1081
|
-
warnings.filterwarnings(
|
|
1082
|
-
"ignore",
|
|
1083
|
-
message=("The function `init_embeddings` is in beta."),
|
|
1084
|
-
)
|
|
1085
|
-
return init_embeddings(embed)
|
langgraph_api/grpc/ops/runs.py
CHANGED
|
@@ -67,6 +67,7 @@ from langgraph_api.priority_settings import (
|
|
|
67
67
|
assign_priority_settings,
|
|
68
68
|
get_priority_callback,
|
|
69
69
|
)
|
|
70
|
+
from langgraph_api.runtime.retry import RETRIABLE_EXCEPTIONS
|
|
70
71
|
from langgraph_api.serde import (
|
|
71
72
|
json_dumpb,
|
|
72
73
|
json_dumpb_optional,
|
|
@@ -625,9 +626,15 @@ class Runs(Authenticated):
|
|
|
625
626
|
offset: int = 0,
|
|
626
627
|
status: RunStatus | None = None,
|
|
627
628
|
select: list[RunSelectField] | None = None,
|
|
629
|
+
before: tuple[datetime, UUID] | None = None,
|
|
628
630
|
ctx: Any = None,
|
|
629
631
|
) -> AsyncIterator[Run]:
|
|
630
|
-
"""List
|
|
632
|
+
"""List a thread's runs, newest first with ties broken by the larger run_id.
|
|
633
|
+
|
|
634
|
+
``before`` is the ``(created_at, run_id)`` of the last run already read;
|
|
635
|
+
only runs after it in that order are returned. It can't be combined
|
|
636
|
+
with a nonzero ``offset``.
|
|
637
|
+
"""
|
|
631
638
|
auth_filters = await Runs.handle_event(
|
|
632
639
|
ctx,
|
|
633
640
|
"search",
|
|
@@ -648,6 +655,12 @@ class Runs(Authenticated):
|
|
|
648
655
|
if select:
|
|
649
656
|
request_kwargs["select"] = select
|
|
650
657
|
|
|
658
|
+
if before is not None:
|
|
659
|
+
created_at, run_id = before
|
|
660
|
+
request_kwargs["before"] = pb.RunSearchCursor(
|
|
661
|
+
created_at=created_at, run_id=pb.UUID(value=str(run_id))
|
|
662
|
+
)
|
|
663
|
+
|
|
651
664
|
client = await get_shared_client()
|
|
652
665
|
response = await client.runs.Search(pb.SearchRunsRequest(**request_kwargs))
|
|
653
666
|
|
|
@@ -1376,7 +1389,6 @@ class Runs(Authenticated):
|
|
|
1376
1389
|
Yields:
|
|
1377
1390
|
ValueEvent that will be set with UserInterrupt() or UserRollback() if cancelled
|
|
1378
1391
|
"""
|
|
1379
|
-
from langgraph_runtime.retry import RETRIABLE_EXCEPTIONS # noqa: PLC0415
|
|
1380
1392
|
|
|
1381
1393
|
@asynccontextmanager
|
|
1382
1394
|
async def _enter_impl():
|
|
@@ -977,9 +977,8 @@ class Threads(Authenticated):
|
|
|
977
977
|
) -> dict[str, Any]:
|
|
978
978
|
"""Get the bytes a thread's checkpoints occupy, per table and per channel.
|
|
979
979
|
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
check as ``get``, so a missing or hidden thread raises 404.
|
|
980
|
+
Go runs the same access check as ``get``, so a missing or hidden
|
|
981
|
+
thread raises 404.
|
|
983
982
|
"""
|
|
984
983
|
auth_filters = await Threads.handle_event(
|
|
985
984
|
ctx, "read", {"thread_id": str(thread_id)}
|
langgraph_api/js/package.json
CHANGED
|
@@ -7,17 +7,17 @@
|
|
|
7
7
|
"format": "prettier --write ."
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@hono/node-server": "^2.1.
|
|
10
|
+
"@hono/node-server": "^2.1.8",
|
|
11
11
|
"@hono/zod-validator": "^0.9.1",
|
|
12
|
-
"@langchain/core": "^1.
|
|
13
|
-
"@langchain/langgraph": "^1.
|
|
12
|
+
"@langchain/core": "^1.4.1",
|
|
13
|
+
"@langchain/langgraph": "^1.7.4",
|
|
14
14
|
"@langchain/langgraph-api": "^1.0.3",
|
|
15
15
|
"@langchain/langgraph-checkpoint": "^1.1.5",
|
|
16
|
-
"@langchain/langgraph-ui": "^1.
|
|
16
|
+
"@langchain/langgraph-ui": "^1.7.2",
|
|
17
17
|
"@types/json-schema": "^7.0.15",
|
|
18
18
|
"dedent": "^1.7.2",
|
|
19
19
|
"exit-hook": "^5.1.0",
|
|
20
|
-
"hono": "^4.13.
|
|
20
|
+
"hono": "^4.13.18",
|
|
21
21
|
"p-queue": "^9.3.1",
|
|
22
22
|
"p-retry": "^7.1.1",
|
|
23
23
|
"typescript": "^6.0.3",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@langchain/langgraph-sdk": "^1.5.4",
|
|
37
|
-
"@types/node": "^26.6.
|
|
37
|
+
"@types/node": "^26.6.6",
|
|
38
38
|
"@types/react": "^19.3.0",
|
|
39
39
|
"@types/react-dom": "^19.3.0",
|
|
40
40
|
"esbuild": "^0.28.2",
|
|
41
|
-
"jose": "^6.2.
|
|
41
|
+
"jose": "^6.2.17",
|
|
42
42
|
"postgres": "^3.4.9",
|
|
43
|
-
"prettier": "^3.
|
|
44
|
-
"vite": "^8.3.
|
|
45
|
-
"vitest": "^5.0
|
|
43
|
+
"prettier": "^3.10.1",
|
|
44
|
+
"vite": "^8.3.8",
|
|
45
|
+
"vitest": "^5.1.0"
|
|
46
46
|
},
|
|
47
47
|
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
|
48
48
|
}
|
langgraph_api/js/remote.py
CHANGED
|
@@ -831,9 +831,9 @@ async def _get_passthrough_checkpointer():
|
|
|
831
831
|
from langgraph_api import _checkpointer as api_checkpointer # noqa: PLC0415
|
|
832
832
|
|
|
833
833
|
checkpointer = await api_checkpointer.get_checkpointer()
|
|
834
|
-
#
|
|
835
|
-
#
|
|
836
|
-
#
|
|
834
|
+
# An InMemorySaver is shared with Python graphs, so swap the serde on a
|
|
835
|
+
# copy; the copy still shares the saved data. Other savers are fresh per
|
|
836
|
+
# call.
|
|
837
837
|
if isinstance(checkpointer, InMemorySaver):
|
|
838
838
|
checkpointer = copy.copy(checkpointer)
|
|
839
839
|
# This checkpointer does not attempt to revive LC-objects.
|