langgraph-executor 0.0.1a2__tar.gz → 0.0.1a4__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.
Files changed (34) hide show
  1. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/PKG-INFO +1 -1
  2. langgraph_executor-0.0.1a4/langgraph_executor/__init__.py +1 -0
  3. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/executor_base.py +43 -5
  4. langgraph_executor-0.0.1a2/langgraph_executor/__init__.py +0 -1
  5. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/.gitignore +0 -0
  6. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/README.md +0 -0
  7. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/common.py +0 -0
  8. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/example.py +0 -0
  9. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/execute_task.py +0 -0
  10. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/executor.py +0 -0
  11. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/extract_graph.py +0 -0
  12. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/info_logger.py +0 -0
  13. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/__init__.py +0 -0
  14. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/executor_pb2.py +0 -0
  15. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/executor_pb2.pyi +0 -0
  16. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/executor_pb2_grpc.py +0 -0
  17. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/executor_pb2_grpc.pyi +0 -0
  18. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/graph_pb2.py +0 -0
  19. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/graph_pb2.pyi +0 -0
  20. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/graph_pb2_grpc.py +0 -0
  21. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/graph_pb2_grpc.pyi +0 -0
  22. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/runtime_pb2.py +0 -0
  23. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/runtime_pb2.pyi +0 -0
  24. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/runtime_pb2_grpc.py +0 -0
  25. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/runtime_pb2_grpc.pyi +0 -0
  26. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/types_pb2.py +0 -0
  27. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/types_pb2.pyi +0 -0
  28. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/types_pb2_grpc.py +0 -0
  29. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/pb/types_pb2_grpc.pyi +0 -0
  30. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/py.typed +0 -0
  31. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/server.py +0 -0
  32. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/setup.sh +0 -0
  33. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/langgraph_executor/stream_utils.py +0 -0
  34. {langgraph_executor-0.0.1a2 → langgraph_executor-0.0.1a4}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langgraph-executor
3
- Version: 0.0.1a2
3
+ Version: 0.0.1a4
4
4
  Summary: LangGraph python RPC server executable by the langgraph-go orchestrator.
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: grpcio>=1.73.1
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1a4"
@@ -3,7 +3,14 @@ import contextlib
3
3
  import functools
4
4
  import logging
5
5
  import uuid
6
- from collections.abc import AsyncIterator, Callable, Collection, Iterator, Sequence
6
+ from collections.abc import (
7
+ AsyncIterator,
8
+ Awaitable,
9
+ Callable,
10
+ Collection,
11
+ Iterator,
12
+ Sequence,
13
+ )
7
14
  from typing import Any, Protocol, cast
8
15
 
9
16
  import grpc
@@ -17,6 +24,7 @@ from langgraph.pregel import Pregel
17
24
  from langgraph.pregel._algo import apply_writes
18
25
  from langgraph.pregel._checkpoint import channels_from_checkpoint
19
26
  from langgraph.pregel._retry import arun_with_retry
27
+ from langgraph.store.base import BaseStore
20
28
  from langgraph.types import PregelExecutableTask
21
29
 
22
30
  from langgraph_executor.common import (
@@ -65,6 +73,16 @@ class LangGraphExecutorServicer(executor_pb2_grpc.LangGraphExecutorServicer):
65
73
  subgraph_map: dict[str, str],
66
74
  get_graph: GetGraph,
67
75
  logger: Logger | None = None,
76
+ on_message: Callable[
77
+ [
78
+ BaseMessageChunk,
79
+ dict[str, Any],
80
+ ],
81
+ None,
82
+ ]
83
+ | None = None,
84
+ on_custom: Callable[[Any], None] | None = None,
85
+ get_store: Callable[[], Awaitable[BaseStore]] | None = None,
68
86
  ):
69
87
  """Initialize the servicer with compiled graphs.
70
88
 
@@ -82,6 +100,9 @@ class LangGraphExecutorServicer(executor_pb2_grpc.LangGraphExecutorServicer):
82
100
  self.get_graph = get_graph
83
101
  _patch_base_message_with_ids()
84
102
  self._graph_definition_cache: dict[str, executor_pb2.GetGraphResponse] = {}
103
+ self.on_message = on_message
104
+ self.on_custom = on_custom
105
+ self.get_store = get_store
85
106
 
86
107
  async def ListGraphs(
87
108
  self, request: Any, context: grpc.aio.ServicerContext
@@ -174,6 +195,7 @@ class LangGraphExecutorServicer(executor_pb2_grpc.LangGraphExecutorServicer):
174
195
  try:
175
196
  request = await _get_init_request(request_iterator)
176
197
  config = reconstruct_config(request.task.config)
198
+ store = await self.get_store() if self.get_store is not None else None
177
199
  async with self.get_graph(request.graph_name, config) as graph:
178
200
  stream_messages = "messages" in request.stream_modes
179
201
  stream_custom = "custom" in request.stream_modes
@@ -181,13 +203,18 @@ class LangGraphExecutorServicer(executor_pb2_grpc.LangGraphExecutorServicer):
181
203
  stream_queue = asyncio.Queue()
182
204
 
183
205
  custom_stream_writer = (
184
- _create_custom_stream_writer(stream_queue, self.logger)
206
+ _create_custom_stream_writer(
207
+ stream_queue, self.logger, on_custom=self.on_custom
208
+ )
185
209
  if stream_custom
186
210
  else None
187
211
  )
188
212
 
189
213
  task = reconstruct_task(
190
- request, graph, custom_stream_writer=custom_stream_writer
214
+ request,
215
+ graph,
216
+ custom_stream_writer=custom_stream_writer,
217
+ store=store,
191
218
  )
192
219
  if stream_messages:
193
220
  # Create and inject callback handler
@@ -196,6 +223,7 @@ class LangGraphExecutorServicer(executor_pb2_grpc.LangGraphExecutorServicer):
196
223
  stream_callback,
197
224
  logger=self.logger,
198
225
  stream_queue=stream_queue,
226
+ on_message=self.on_message,
199
227
  ),
200
228
  task.id,
201
229
  )
@@ -362,13 +390,16 @@ async def _run_task(
362
390
 
363
391
  def stream_callback(
364
392
  message: BaseMessageChunk,
365
- metadata: dict,
393
+ metadata: dict[str, Any],
366
394
  *,
367
395
  logger: Logger,
368
396
  stream_queue: asyncio.Queue[executor_pb2.ExecuteTaskResponse],
397
+ on_message: Callable[[BaseMessageChunk, dict[str, Any]], None] | None = None,
369
398
  ):
370
399
  """Callback to capture stream chunks and queue them."""
371
400
  try:
401
+ if on_message is not None:
402
+ on_message(message, metadata)
372
403
  stream_queue.put_nowait(
373
404
  executor_pb2.ExecuteTaskResponse(
374
405
  message_or_message_chunk=_extract_output_message(message)
@@ -378,12 +409,19 @@ def stream_callback(
378
409
  logger.warning(f"Failed to create stream chunk: {e}", exc_info=True)
379
410
 
380
411
 
381
- def _create_custom_stream_writer(stream_queue: asyncio.Queue[Any], logger: Logger):
412
+ def _create_custom_stream_writer(
413
+ stream_queue: asyncio.Queue[Any],
414
+ logger: Logger,
415
+ *,
416
+ on_custom: Callable[[Any], None] | None = None,
417
+ ):
382
418
  """Create a proper stream_writer function for custom mode (like langgraph does)."""
383
419
 
384
420
  def stream_writer(content):
385
421
  """Custom stream writer that creates CustomStreamEvent messages."""
386
422
  try:
423
+ if on_custom is not None:
424
+ on_custom(content)
387
425
  # Create payload struct (like langgraph does)
388
426
  payload = Struct()
389
427
  if isinstance(content, str):
@@ -1 +0,0 @@
1
- __version__ = "0.0.1a2"