langgraph-api 0.0.1__tar.gz → 0.0.3__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.

Potentially problematic release.


This version of langgraph-api might be problematic. Click here for more details.

Files changed (85) hide show
  1. langgraph_api-0.0.3/PKG-INFO +130 -0
  2. langgraph_api-0.0.3/README.md +101 -0
  3. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/cli.py +7 -5
  4. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/graph.py +23 -13
  5. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/hooks.mjs +5 -1
  6. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/queue.py +9 -1
  7. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/schema.py +2 -0
  8. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/stream.py +6 -1
  9. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_license/validation.py +1 -1
  10. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/checkpoint.py +3 -1
  11. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/ops.py +9 -0
  12. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/pyproject.toml +4 -2
  13. langgraph_api-0.0.1/PKG-INFO +0 -26
  14. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/LICENSE +0 -0
  15. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/__init__.py +0 -0
  16. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/api/__init__.py +0 -0
  17. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/api/assistants.py +0 -0
  18. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/api/meta.py +0 -0
  19. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/api/openapi.py +0 -0
  20. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/api/runs.py +0 -0
  21. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/api/store.py +0 -0
  22. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/api/threads.py +0 -0
  23. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/asyncio.py +0 -0
  24. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/auth/__init__.py +0 -0
  25. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/auth/langsmith/__init__.py +0 -0
  26. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/auth/langsmith/backend.py +0 -0
  27. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/auth/langsmith/client.py +0 -0
  28. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/auth/middleware.py +0 -0
  29. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/auth/noop.py +0 -0
  30. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/config.py +0 -0
  31. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/cron_scheduler.py +0 -0
  32. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/errors.py +0 -0
  33. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/http.py +0 -0
  34. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/http_logger.py +0 -0
  35. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/.gitignore +0 -0
  36. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/build.mts +0 -0
  37. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/client.mts +0 -0
  38. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/global.d.ts +0 -0
  39. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/package.json +0 -0
  40. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/remote.py +0 -0
  41. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/server_sent_events.py +0 -0
  42. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/graph.mts +0 -0
  43. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/parser/parser.mts +0 -0
  44. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/parser/parser.worker.mjs +0 -0
  45. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/schema/types.mts +0 -0
  46. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/schema/types.template.mts +0 -0
  47. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/utils/importMap.mts +0 -0
  48. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/utils/pythonSchemas.mts +0 -0
  49. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/src/utils/serde.mts +0 -0
  50. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/api.test.mts +0 -0
  51. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/compose-postgres.yml +0 -0
  52. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/.gitignore +0 -0
  53. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/agent.mts +0 -0
  54. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/error.mts +0 -0
  55. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/langgraph.json +0 -0
  56. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/nested.mts +0 -0
  57. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/package.json +0 -0
  58. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/weather.mts +0 -0
  59. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/graphs/yarn.lock +0 -0
  60. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/parser.test.mts +0 -0
  61. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/tests/utils.mts +0 -0
  62. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/js/yarn.lock +0 -0
  63. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/lifespan.py +0 -0
  64. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/logging.py +0 -0
  65. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/metadata.py +0 -0
  66. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/models/__init__.py +0 -0
  67. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/models/run.py +0 -0
  68. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/patch.py +0 -0
  69. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/route.py +0 -0
  70. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/serde.py +0 -0
  71. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/server.py +0 -0
  72. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/sse.py +0 -0
  73. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/state.py +0 -0
  74. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/utils.py +0 -0
  75. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_api/validation.py +0 -0
  76. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_license/__init__.py +0 -0
  77. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_license/middleware.py +0 -0
  78. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/__init__.py +0 -0
  79. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/database.py +0 -0
  80. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/queue.py +0 -0
  81. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/retry.py +0 -0
  82. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/store.py +0 -0
  83. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/langgraph_storage/ttl_dict.py +0 -0
  84. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/logging.json +0 -0
  85. {langgraph_api-0.0.1 → langgraph_api-0.0.3}/openapi.json +0 -0
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.1
2
+ Name: langgraph-api
3
+ Version: 0.0.3
4
+ Summary:
5
+ License: Elastic-2.0
6
+ Author: Nuno Campos
7
+ Author-email: nuno@langchain.dev
8
+ Requires-Python: >=3.11.0,<4.0
9
+ Classifier: License :: Other/Proprietary License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Requires-Dist: cryptography (>=43.0.3,<44.0.0)
14
+ Requires-Dist: httpx (>=0.27.0)
15
+ Requires-Dist: jsonschema-rs (>=0.25.0,<0.26.0)
16
+ Requires-Dist: langchain-core (>=0.2.38,<0.4.0)
17
+ Requires-Dist: langgraph (>=0.2.52,<0.3.0)
18
+ Requires-Dist: langgraph-checkpoint (>=2.0.5,<3.0)
19
+ Requires-Dist: langsmith (>=0.1.63,<0.2.0)
20
+ Requires-Dist: orjson (>=3.10.1)
21
+ Requires-Dist: pyjwt (>=2.9.0,<3.0.0)
22
+ Requires-Dist: sse-starlette (>=2.1.0,<3.0.0)
23
+ Requires-Dist: starlette (>=0.38.6)
24
+ Requires-Dist: structlog (>=24.4.0,<25.0.0)
25
+ Requires-Dist: tenacity (>=8.3.0,<9.0.0)
26
+ Requires-Dist: uvicorn (>=0.26.0)
27
+ Requires-Dist: watchfiles (>=0.13)
28
+ Description-Content-Type: text/markdown
29
+
30
+ # LangGraph API
31
+
32
+ This package implements the LangGraph API for rapid development and testing. Build and iterate on LangGraph agents with a tight feedback loop. The sesrver is backed by a predominently in-memory data store that is persisted to local disk when the server is restarted.
33
+
34
+ For production use, see the various [deployment options](https://langchain-ai.github.io/langgraph/concepts/deployment_options/) for the LangGraph API, which are backed by a production-grade database.
35
+
36
+ ## Installation
37
+
38
+ Install the `langgraph-cli` package with the `inmem` extra. Your CLI version must be no lower than `0.1.55`.
39
+
40
+ ```bash
41
+ pip install -U langgraph-cli[inmem]
42
+ ```
43
+
44
+ ## Quickstart
45
+
46
+ 1. (Optional) Clone a starter template:
47
+
48
+ ```bash
49
+ langgraph new --template new-langgraph-project-python ./my-project
50
+ cd my-project
51
+ ```
52
+
53
+ (Recommended) Use a virtual environment and install dependencies:
54
+
55
+ ```bash
56
+ python -m venv .venv
57
+ source .venv/bin/activate
58
+ python -m pip install .
59
+ ```
60
+
61
+ 2. Start the development server:
62
+
63
+ ```shell
64
+ langgraph dev --config ./langgraph.json
65
+ ```
66
+
67
+ 3. The server will launch, opening a browser window with the graph UI. Interact with your graph or make code edits; the server automatically reloads on changes.
68
+
69
+ ## Usage
70
+
71
+ Start the development server:
72
+
73
+ ```bash
74
+ langgraph dev
75
+ ```
76
+
77
+ Your agent's state (threads, runs, assistants) persists in memory while the server is running - perfect for development and testing. Each run's state is tracked and can be inspected, making it easy to debug and improve your agent's behavior.
78
+
79
+ ## How-To
80
+
81
+ #### Attaching a debugger
82
+ Debug mode lets you attach your IDE's debugger to the LangGraph API server to set breakpoints and step through your code line-by-line.
83
+
84
+ 1. Install debugpy:
85
+
86
+ ```bash
87
+ pip install debugpy
88
+ ```
89
+
90
+ 2. Start the server in debug mode:
91
+
92
+ ```bash
93
+ langgraph dev --debug-port 5678
94
+ ```
95
+
96
+ 3. Configure your IDE:
97
+
98
+ - **VS Code**: Add this launch configuration:
99
+ ```json
100
+ {
101
+ "name": "Attach to LangGraph",
102
+ "type": "debugpy",
103
+ "request": "attach",
104
+ "connect": {
105
+ "host": "0.0.0.0",
106
+ "port": 5678
107
+ },
108
+ }
109
+ ```
110
+ - **PyCharm**: Use "Attach to Process" and select the langgraph process
111
+
112
+ 4. Set breakpoints in your graph code and start debugging.
113
+
114
+ ## CLI options
115
+
116
+ ```bash
117
+ langgraph dev [OPTIONS]
118
+ Options:
119
+ --debug-port INTEGER Enable remote debugging on specified port
120
+ --no-browser Skip opening browser on startup
121
+ --n-jobs-per-worker INTEGER Maximum concurrent jobs per worker process
122
+ --config PATH Custom configuration file path
123
+ --no-reload Disable code hot reloading
124
+ --port INTEGER HTTP server port (default: 8000)
125
+ --host TEXT HTTP server host (default: localhost)
126
+ ```
127
+
128
+ ## License
129
+
130
+ This project is licensed under the Elastic License 2.0 - see the [LICENSE](./LICENSE) file for details.
@@ -0,0 +1,101 @@
1
+ # LangGraph API
2
+
3
+ This package implements the LangGraph API for rapid development and testing. Build and iterate on LangGraph agents with a tight feedback loop. The sesrver is backed by a predominently in-memory data store that is persisted to local disk when the server is restarted.
4
+
5
+ For production use, see the various [deployment options](https://langchain-ai.github.io/langgraph/concepts/deployment_options/) for the LangGraph API, which are backed by a production-grade database.
6
+
7
+ ## Installation
8
+
9
+ Install the `langgraph-cli` package with the `inmem` extra. Your CLI version must be no lower than `0.1.55`.
10
+
11
+ ```bash
12
+ pip install -U langgraph-cli[inmem]
13
+ ```
14
+
15
+ ## Quickstart
16
+
17
+ 1. (Optional) Clone a starter template:
18
+
19
+ ```bash
20
+ langgraph new --template new-langgraph-project-python ./my-project
21
+ cd my-project
22
+ ```
23
+
24
+ (Recommended) Use a virtual environment and install dependencies:
25
+
26
+ ```bash
27
+ python -m venv .venv
28
+ source .venv/bin/activate
29
+ python -m pip install .
30
+ ```
31
+
32
+ 2. Start the development server:
33
+
34
+ ```shell
35
+ langgraph dev --config ./langgraph.json
36
+ ```
37
+
38
+ 3. The server will launch, opening a browser window with the graph UI. Interact with your graph or make code edits; the server automatically reloads on changes.
39
+
40
+ ## Usage
41
+
42
+ Start the development server:
43
+
44
+ ```bash
45
+ langgraph dev
46
+ ```
47
+
48
+ Your agent's state (threads, runs, assistants) persists in memory while the server is running - perfect for development and testing. Each run's state is tracked and can be inspected, making it easy to debug and improve your agent's behavior.
49
+
50
+ ## How-To
51
+
52
+ #### Attaching a debugger
53
+ Debug mode lets you attach your IDE's debugger to the LangGraph API server to set breakpoints and step through your code line-by-line.
54
+
55
+ 1. Install debugpy:
56
+
57
+ ```bash
58
+ pip install debugpy
59
+ ```
60
+
61
+ 2. Start the server in debug mode:
62
+
63
+ ```bash
64
+ langgraph dev --debug-port 5678
65
+ ```
66
+
67
+ 3. Configure your IDE:
68
+
69
+ - **VS Code**: Add this launch configuration:
70
+ ```json
71
+ {
72
+ "name": "Attach to LangGraph",
73
+ "type": "debugpy",
74
+ "request": "attach",
75
+ "connect": {
76
+ "host": "0.0.0.0",
77
+ "port": 5678
78
+ },
79
+ }
80
+ ```
81
+ - **PyCharm**: Use "Attach to Process" and select the langgraph process
82
+
83
+ 4. Set breakpoints in your graph code and start debugging.
84
+
85
+ ## CLI options
86
+
87
+ ```bash
88
+ langgraph dev [OPTIONS]
89
+ Options:
90
+ --debug-port INTEGER Enable remote debugging on specified port
91
+ --no-browser Skip opening browser on startup
92
+ --n-jobs-per-worker INTEGER Maximum concurrent jobs per worker process
93
+ --config PATH Custom configuration file path
94
+ --no-reload Disable code hot reloading
95
+ --port INTEGER HTTP server port (default: 8000)
96
+ --host TEXT HTTP server host (default: localhost)
97
+ ```
98
+
99
+ ## License
100
+
101
+ This project is licensed under the Elastic License 2.0 - see the [LICENSE](./LICENSE) file for details.
@@ -4,7 +4,7 @@ import logging
4
4
  import os
5
5
  import pathlib
6
6
  import threading
7
- from collections.abc import Mapping
7
+ from collections.abc import Mapping, Sequence
8
8
 
9
9
  logging.basicConfig(level=logging.INFO)
10
10
  logger = logging.getLogger(__name__)
@@ -47,6 +47,8 @@ def run_server(
47
47
  open_browser: bool = False,
48
48
  debug_port: int | None = None,
49
49
  env: str | pathlib.Path | Mapping[str, str] | None = None,
50
+ reload_includes: Sequence[str] | None = None,
51
+ reload_excludes: Sequence[str] | None = None,
50
52
  ):
51
53
  """Run the LangGraph API server."""
52
54
  import uvicorn
@@ -127,7 +129,7 @@ For production use, please use LangGraph Cloud.
127
129
  REDIS_URI="fake",
128
130
  N_JOBS_PER_WORKER=str(n_jobs_per_worker if n_jobs_per_worker else 1),
129
131
  LANGSERVE_GRAPHS=json.dumps(graphs) if graphs else None,
130
- LANGSMITH_LANGGRAPH_API_VARIANT="test",
132
+ LANGSMITH_LANGGRAPH_API_VARIANT="local_dev",
131
133
  **(env_vars or {}),
132
134
  ):
133
135
  if open_browser:
@@ -140,13 +142,13 @@ For production use, please use LangGraph Cloud.
140
142
  reload=reload,
141
143
  env_file=env_file,
142
144
  access_log=False,
145
+ reload_includes=reload_includes,
146
+ reload_excludes=reload_excludes,
143
147
  log_config={
144
148
  "version": 1,
145
149
  "incremental": False,
146
150
  "disable_existing_loggers": False,
147
- "formatters": {
148
- "simple": {"class": "langgraph_api.logging.Formatter"}
149
- },
151
+ "formatters": {"simple": {"class": "langgraph_api.logging.Formatter"}},
150
152
  "handlers": {
151
153
  "console": {
152
154
  "class": "logging.StreamHandler",
@@ -157,18 +157,20 @@ async def collect_graphs_from_env(register: bool = False) -> None:
157
157
 
158
158
  if paths_str:
159
159
  specs = [
160
- GraphSpec(
161
- key,
162
- module=value.split(":")[0],
163
- variable=value.split(":")[1],
164
- config=config_per_graph.get(key),
165
- )
166
- if "/" not in value
167
- else GraphSpec(
168
- key,
169
- path=value.split(":")[0],
170
- variable=value.split(":")[1],
171
- config=config_per_graph.get(key),
160
+ (
161
+ GraphSpec(
162
+ key,
163
+ module=value.split(":")[0],
164
+ variable=value.split(":")[1],
165
+ config=config_per_graph.get(key),
166
+ )
167
+ if "/" not in value
168
+ else GraphSpec(
169
+ key,
170
+ path=value.split(":")[0],
171
+ variable=value.split(":")[1],
172
+ config=config_per_graph.get(key),
173
+ )
172
174
  )
173
175
  for key, value in json.loads(paths_str).items()
174
176
  ]
@@ -268,7 +270,15 @@ def _graph_from_spec(spec: GraphSpec) -> GraphValue:
268
270
  modspec.loader.exec_module(module)
269
271
  except ImportError as e:
270
272
  e.add_note(f"Could not import python module for graph: {spec}")
271
- raise e
273
+ if os.environ.get("LANGSMITH_LANGGRAPH_API_VARIANT") == "local_dev":
274
+ e.add_note(
275
+ "This error likely means you haven't installed your project and its dependencies yet. Before running the server, install your project:\n\n"
276
+ "If you are using requirements.txt:\n"
277
+ "python -m pip install -r requirements.txt\n\n"
278
+ "If you are using pyproject.toml or setuptools:\n"
279
+ "python -m pip install -e .\n\n"
280
+ "Make sure to run this command from your project's root directory (where your setup.py or pyproject.toml is located)"
281
+ )
272
282
  else:
273
283
  raise ValueError("Graph specification must have a path or module")
274
284
 
@@ -5,7 +5,11 @@ export async function resolve(specifier, context, nextResolve) {
5
5
  const parentURL = new URL("./graph.mts", import.meta.url).toString();
6
6
 
7
7
  if (specifier.startsWith("@langchain/langgraph")) {
8
- return nextResolve(specifier, { ...context, parentURL });
8
+ try {
9
+ return nextResolve(specifier, { ...context, parentURL });
10
+ } catch (error) {
11
+ return nextResolve(specifier, context);
12
+ }
9
13
  }
10
14
 
11
15
  return nextResolve(specifier, context);
@@ -5,7 +5,7 @@ from random import random
5
5
  from typing import cast
6
6
 
7
7
  import structlog
8
- from langgraph.pregel.debug import CheckpointPayload
8
+ from langgraph.pregel.debug import CheckpointPayload, TaskResultPayload
9
9
 
10
10
  from langgraph_api.config import BG_JOB_NO_DELAY, STATS_INTERVAL_SECS
11
11
  from langgraph_api.errors import (
@@ -129,6 +129,13 @@ async def worker(
129
129
  nonlocal checkpoint
130
130
  checkpoint = checkpoint_arg
131
131
 
132
+ def on_task_result(task_result: TaskResultPayload):
133
+ if checkpoint is not None:
134
+ for task in checkpoint["tasks"]:
135
+ if task["id"] == task_result["id"]:
136
+ task.update(task_result)
137
+ break
138
+
132
139
  try:
133
140
  if attempt > MAX_RETRY_ATTEMPTS:
134
141
  raise RuntimeError(f"Run {run['run_id']} exceeded max attempts")
@@ -144,6 +151,7 @@ async def worker(
144
151
  attempt,
145
152
  done,
146
153
  on_checkpoint=on_checkpoint,
154
+ on_task_result=on_task_result,
147
155
  )
148
156
  await asyncio.wait_for(consume(stream, run_id), timeout)
149
157
  await logger.ainfo(
@@ -98,6 +98,8 @@ class Thread(TypedDict):
98
98
  """The status of the thread. One of 'idle', 'busy', 'interrupted', "error"."""
99
99
  values: Fragment
100
100
  """The current state of the thread."""
101
+ interrupts: Fragment
102
+ """The current interrupts of the thread, a map of task_id to list of interrupts."""
101
103
 
102
104
 
103
105
  class ThreadTask(TypedDict):
@@ -18,7 +18,7 @@ from langgraph.errors import (
18
18
  GraphRecursionError,
19
19
  InvalidUpdateError,
20
20
  )
21
- from langgraph.pregel.debug import CheckpointPayload
21
+ from langgraph.pregel.debug import CheckpointPayload, TaskResultPayload
22
22
  from langgraph.types import Command, Send
23
23
  from pydantic import ValidationError
24
24
  from pydantic.v1 import ValidationError as ValidationErrorLegacy
@@ -90,6 +90,7 @@ async def astream_state(
90
90
  done: ValueEvent,
91
91
  *,
92
92
  on_checkpoint: Callable[[CheckpointPayload], None] = lambda _: None,
93
+ on_task_result: Callable[[TaskResultPayload], None] = lambda _: None,
93
94
  ) -> AnyStream:
94
95
  """Stream messages from the runnable."""
95
96
  run_id = str(run["run_id"])
@@ -174,6 +175,8 @@ async def astream_state(
174
175
  if chunk["type"] == "checkpoint":
175
176
  checkpoint = _preprocess_debug_checkpoint(chunk["payload"])
176
177
  on_checkpoint(checkpoint)
178
+ elif chunk["type"] == "task_result":
179
+ on_task_result(chunk["payload"])
177
180
  if mode == "messages":
178
181
  if "messages-tuple" in stream_mode:
179
182
  yield "messages", chunk
@@ -221,6 +224,8 @@ async def astream_state(
221
224
  if chunk["type"] == "checkpoint":
222
225
  checkpoint = _preprocess_debug_checkpoint(chunk["payload"])
223
226
  on_checkpoint(checkpoint)
227
+ elif chunk["type"] == "task_result":
228
+ on_task_result(chunk["payload"])
224
229
  if mode == "messages":
225
230
  if "messages-tuple" in stream_mode:
226
231
  yield "messages", chunk
@@ -7,5 +7,5 @@ async def get_license_status() -> bool:
7
7
 
8
8
 
9
9
  def plus_features_enabled() -> bool:
10
- """Always return true"""
10
+ """Always return false"""
11
11
  return False
@@ -10,6 +10,8 @@ from langgraph.checkpoint.base import (
10
10
  )
11
11
  from langgraph.checkpoint.memory import MemorySaver, PersistentDict
12
12
 
13
+ from langgraph_api.serde import Serializer
14
+
13
15
  _EXCLUDED_KEYS = {"checkpoint_ns", "checkpoint_id", "run_id", "thread_id"}
14
16
 
15
17
 
@@ -37,7 +39,7 @@ class InMemorySaver(MemorySaver):
37
39
  return d
38
40
 
39
41
  super().__init__(
40
- serde=serde,
42
+ serde=serde if serde is not None else Serializer(),
41
43
  factory=factory,
42
44
  )
43
45
 
@@ -583,6 +583,15 @@ class Threads:
583
583
  "updated_at": datetime.now(UTC),
584
584
  "values": checkpoint["values"] if checkpoint else None,
585
585
  "status": status,
586
+ "interrupts": (
587
+ {
588
+ t["id"]: t["interrupts"]
589
+ for t in checkpoint["tasks"]
590
+ if t["interrupts"]
591
+ }
592
+ if checkpoint
593
+ else {}
594
+ ),
586
595
  }
587
596
  )
588
597
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "langgraph-api"
3
- version = "0.0.1"
3
+ version = "0.0.3"
4
4
  description = ""
5
5
  authors = [
6
6
  "Nuno Campos <nuno@langchain.dev>",
@@ -12,6 +12,7 @@ packages = [
12
12
  { include = "langgraph_storage" },
13
13
  { include = "langgraph_license" },
14
14
  ]
15
+ readme = "README.md"
15
16
  include = ["LICENSE", "openapi.json", "logging.json"]
16
17
 
17
18
  [tool.poetry.scripts]
@@ -22,7 +23,8 @@ python = ">=3.11.0,<4.0"
22
23
  sse-starlette = "^2.1.0"
23
24
  starlette = ">=0.38.6"
24
25
  watchfiles = ">=0.13"
25
- langgraph = ">=0.2.52"
26
+ langgraph = ">=0.2.52,<0.3.0"
27
+ langgraph-checkpoint = ">=2.0.5,<3.0"
26
28
  orjson = ">=3.10.1"
27
29
  uvicorn = ">=0.26.0"
28
30
  langsmith = "^0.1.63"
@@ -1,26 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: langgraph-api
3
- Version: 0.0.1
4
- Summary:
5
- License: Elastic-2.0
6
- Author: Nuno Campos
7
- Author-email: nuno@langchain.dev
8
- Requires-Python: >=3.11.0,<4.0
9
- Classifier: License :: Other/Proprietary License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.11
12
- Classifier: Programming Language :: Python :: 3.12
13
- Requires-Dist: cryptography (>=43.0.3,<44.0.0)
14
- Requires-Dist: httpx (>=0.27.0)
15
- Requires-Dist: jsonschema-rs (>=0.25.0,<0.26.0)
16
- Requires-Dist: langchain-core (>=0.2.38,<0.4.0)
17
- Requires-Dist: langgraph (>=0.2.52)
18
- Requires-Dist: langsmith (>=0.1.63,<0.2.0)
19
- Requires-Dist: orjson (>=3.10.1)
20
- Requires-Dist: pyjwt (>=2.9.0,<3.0.0)
21
- Requires-Dist: sse-starlette (>=2.1.0,<3.0.0)
22
- Requires-Dist: starlette (>=0.38.6)
23
- Requires-Dist: structlog (>=24.4.0,<25.0.0)
24
- Requires-Dist: tenacity (>=8.3.0,<9.0.0)
25
- Requires-Dist: uvicorn (>=0.26.0)
26
- Requires-Dist: watchfiles (>=0.13)
File without changes