langgraph-runtime-inmem 0.23.0__py3-none-any.whl → 0.23.2__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_runtime_inmem/__init__.py +1 -1
- langgraph_runtime_inmem/_persistence.py +6 -0
- langgraph_runtime_inmem/lifespan.py +1 -2
- langgraph_runtime_inmem/ops.py +18 -0
- langgraph_runtime_inmem/routes.py +7 -0
- langgraph_runtime_inmem/store.py +13 -13
- {langgraph_runtime_inmem-0.23.0.dist-info → langgraph_runtime_inmem-0.23.2.dist-info}/METADATA +1 -1
- langgraph_runtime_inmem-0.23.2.dist-info/RECORD +15 -0
- langgraph_runtime_inmem-0.23.0.dist-info/RECORD +0 -15
- {langgraph_runtime_inmem-0.23.0.dist-info → langgraph_runtime_inmem-0.23.2.dist-info}/WHEEL +0 -0
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import functools
|
|
6
6
|
import logging
|
|
7
|
+
import os
|
|
7
8
|
import threading
|
|
8
9
|
import weakref
|
|
9
10
|
|
|
@@ -14,10 +15,15 @@ logger = logging.getLogger(__name__)
|
|
|
14
15
|
_stores: dict[str, weakref.ref[PersistentDict]] = {}
|
|
15
16
|
_flush_thread: tuple[threading.Event, threading.Thread] | None = None
|
|
16
17
|
_flush_interval: int = 10
|
|
18
|
+
DISABLE_FILE_PERSISTENCE = (
|
|
19
|
+
os.getenv("LANGGRAPH_DISABLE_FILE_PERSISTENCE", "false").lower() == "true"
|
|
20
|
+
)
|
|
17
21
|
|
|
18
22
|
|
|
19
23
|
def register_persistent_dict(d: PersistentDict) -> None:
|
|
20
24
|
"""Register a PersistentDict for periodic flushing."""
|
|
25
|
+
if DISABLE_FILE_PERSISTENCE:
|
|
26
|
+
return
|
|
21
27
|
global _flush_thread
|
|
22
28
|
_stores[d.filename] = weakref.ref(d)
|
|
23
29
|
if _flush_thread is None:
|
|
@@ -29,7 +29,7 @@ async def lifespan(
|
|
|
29
29
|
**kwargs: Any,
|
|
30
30
|
):
|
|
31
31
|
import langgraph_api.config as config
|
|
32
|
-
from langgraph_api import __version__, feature_flags, graph
|
|
32
|
+
from langgraph_api import __version__, feature_flags, graph
|
|
33
33
|
from langgraph_api import (
|
|
34
34
|
_checkpointer as api_checkpointer,
|
|
35
35
|
)
|
|
@@ -87,7 +87,6 @@ async def lifespan(
|
|
|
87
87
|
tg.create_task(store_instance.start_ttl_sweeper()) # type: ignore
|
|
88
88
|
else:
|
|
89
89
|
await logger.ainfo("Using custom store. Skipping store TTL sweeper.")
|
|
90
|
-
tg.create_task(thread_ttl.thread_ttl_sweep_loop())
|
|
91
90
|
|
|
92
91
|
if feature_flags.USE_RUNTIME_CONTEXT_API:
|
|
93
92
|
from langgraph._internal._constants import CONFIG_KEY_RUNTIME
|
langgraph_runtime_inmem/ops.py
CHANGED
|
@@ -253,6 +253,7 @@ class Assistants(Authenticated):
|
|
|
253
253
|
name: str,
|
|
254
254
|
ctx: Auth.types.BaseAuthContext | None = None,
|
|
255
255
|
description: str | None = None,
|
|
256
|
+
system: bool = False,
|
|
256
257
|
) -> AsyncIterator[Assistant]:
|
|
257
258
|
"""Insert an assistant."""
|
|
258
259
|
from langgraph_api.graph import assert_graph_exists
|
|
@@ -3003,6 +3004,22 @@ class Crons:
|
|
|
3003
3004
|
on_run_completed: Literal["delete", "keep"] | None = None,
|
|
3004
3005
|
end_time: datetime | None = None,
|
|
3005
3006
|
metadata: dict | None = None,
|
|
3007
|
+
enabled: bool,
|
|
3008
|
+
ctx: Auth.types.BaseAuthContext | None = None,
|
|
3009
|
+
) -> AsyncIterator[Cron]:
|
|
3010
|
+
raise NotImplementedError
|
|
3011
|
+
|
|
3012
|
+
@staticmethod
|
|
3013
|
+
async def update(
|
|
3014
|
+
conn: InMemConnectionProto,
|
|
3015
|
+
*,
|
|
3016
|
+
cron_id: UUID,
|
|
3017
|
+
schedule: str | None = None,
|
|
3018
|
+
end_time: datetime | None = None,
|
|
3019
|
+
enabled: bool | None = None,
|
|
3020
|
+
on_run_completed: Literal["delete", "keep"] | None = None,
|
|
3021
|
+
payload: dict | None = None,
|
|
3022
|
+
metadata: dict | None = None,
|
|
3006
3023
|
ctx: Auth.types.BaseAuthContext | None = None,
|
|
3007
3024
|
) -> AsyncIterator[Cron]:
|
|
3008
3025
|
raise NotImplementedError
|
|
@@ -3038,6 +3055,7 @@ class Crons:
|
|
|
3038
3055
|
*,
|
|
3039
3056
|
assistant_id: UUID | None,
|
|
3040
3057
|
thread_id: UUID | None,
|
|
3058
|
+
enabled: bool,
|
|
3041
3059
|
limit: int,
|
|
3042
3060
|
offset: int,
|
|
3043
3061
|
select: list[CronSelectField] | None = None,
|
|
@@ -8,6 +8,13 @@ from langgraph_runtime_inmem.database import connect
|
|
|
8
8
|
def get_internal_routes():
|
|
9
9
|
from langgraph_api.config import MIGRATIONS_PATH
|
|
10
10
|
|
|
11
|
+
try:
|
|
12
|
+
from langgraph_api.middleware import http_logger
|
|
13
|
+
|
|
14
|
+
http_logger.PATHS_IGNORE.add("/internal/truncate")
|
|
15
|
+
except ImportError:
|
|
16
|
+
pass
|
|
17
|
+
|
|
11
18
|
if "__inmem" not in MIGRATIONS_PATH:
|
|
12
19
|
# not in a testing mode.
|
|
13
20
|
return []
|
langgraph_runtime_inmem/store.py
CHANGED
|
@@ -10,29 +10,27 @@ from langgraph.store.base import BaseStore, Op, Result
|
|
|
10
10
|
from langgraph.store.base.batch import AsyncBatchedBaseStore
|
|
11
11
|
from langgraph.store.memory import InMemoryStore
|
|
12
12
|
|
|
13
|
-
from langgraph_runtime_inmem
|
|
13
|
+
from langgraph_runtime_inmem import _persistence
|
|
14
14
|
|
|
15
15
|
_STORE_CONFIG = None
|
|
16
|
-
DISABLE_FILE_PERSISTENCE = (
|
|
17
|
-
os.getenv("LANGGRAPH_DISABLE_FILE_PERSISTENCE", "false").lower() == "true"
|
|
18
|
-
)
|
|
19
16
|
|
|
20
17
|
|
|
21
18
|
class DiskBackedInMemStore(InMemoryStore):
|
|
22
19
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
23
20
|
super().__init__(*args, **kwargs)
|
|
24
|
-
if not DISABLE_FILE_PERSISTENCE:
|
|
21
|
+
if not _persistence.DISABLE_FILE_PERSISTENCE:
|
|
25
22
|
self._data = PersistentDict(dict, filename=_STORE_FILE)
|
|
26
23
|
self._vectors = PersistentDict(
|
|
27
24
|
lambda: defaultdict(dict), filename=_VECTOR_FILE
|
|
28
25
|
)
|
|
29
|
-
register_persistent_dict(self._data)
|
|
30
|
-
register_persistent_dict(self._vectors)
|
|
26
|
+
_persistence.register_persistent_dict(self._data)
|
|
27
|
+
_persistence.register_persistent_dict(self._vectors)
|
|
28
|
+
self._load_data(self._data, which="data")
|
|
29
|
+
self._load_data(self._vectors, which="vectors")
|
|
31
30
|
else:
|
|
32
|
-
self._data =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
self._load_data(self._vectors, which="vectors")
|
|
31
|
+
self._data = defaultdict(dict)
|
|
32
|
+
# [ns][key][path]
|
|
33
|
+
self._vectors = defaultdict(lambda: defaultdict(dict))
|
|
36
34
|
|
|
37
35
|
def _load_data(self, container: PersistentDict, which: str) -> None:
|
|
38
36
|
if not container.filename:
|
|
@@ -58,8 +56,10 @@ class DiskBackedInMemStore(InMemoryStore):
|
|
|
58
56
|
return asyncio.create_task(asyncio.sleep(0))
|
|
59
57
|
|
|
60
58
|
def close(self) -> None:
|
|
61
|
-
self._data
|
|
62
|
-
|
|
59
|
+
if isinstance(self._data, PersistentDict):
|
|
60
|
+
self._data.close()
|
|
61
|
+
if isinstance(self._vectors, PersistentDict):
|
|
62
|
+
self._vectors.close()
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
class BatchedStore(AsyncBatchedBaseStore):
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
langgraph_runtime_inmem/__init__.py,sha256=IfmL9kXBjvAhwVwQVwlbKnJMJv_q3hKtHE_zOkCU17I,337
|
|
2
|
+
langgraph_runtime_inmem/_persistence.py,sha256=0h_HLXc079TG0rXoiQjICPZLhhBpTsmZ2PG8UbB5YY4,1879
|
|
3
|
+
langgraph_runtime_inmem/checkpoint.py,sha256=VD5c6CktsToo_f4qPe1WP_csdonQoOb7h5lHv4U0ZAE,8372
|
|
4
|
+
langgraph_runtime_inmem/database.py,sha256=iP7W1SI4kUkqcHtkg3aMmP-YLgZfvMHANwN-P4Pb1pY,6607
|
|
5
|
+
langgraph_runtime_inmem/inmem_stream.py,sha256=PFLWbsxU8RqbT5mYJgNk6v5q6TWJRIY1hkZWhJF8nkI,9094
|
|
6
|
+
langgraph_runtime_inmem/lifespan.py,sha256=zprYeZ05QfYJIa7h7KCeAJSDSpnvo-JWvwoQIXFZX2w,4860
|
|
7
|
+
langgraph_runtime_inmem/metrics.py,sha256=_YiSkLnhQvHpMktk38SZo0abyL-5GihfVAtBo0-lFIc,403
|
|
8
|
+
langgraph_runtime_inmem/ops.py,sha256=u6T1S90mqEg5CsMPu3jZrIxRJzArVvgyNVbYBvRiCQw,121370
|
|
9
|
+
langgraph_runtime_inmem/queue.py,sha256=WM6ZJu25QPVjFXeJYW06GALLUgRsnRrA4YdypR0oG0U,9584
|
|
10
|
+
langgraph_runtime_inmem/retry.py,sha256=XmldOP4e_H5s264CagJRVnQMDFcEJR_dldVR1Hm5XvM,763
|
|
11
|
+
langgraph_runtime_inmem/routes.py,sha256=25W-8fQCmBD3MHTv91GIGgBl8tfl-MovdXDd34yVkzM,1541
|
|
12
|
+
langgraph_runtime_inmem/store.py,sha256=EehjI-LWemnMYqDeMJp75hvZK8oInZL-JhnfnEwtlPk,3751
|
|
13
|
+
langgraph_runtime_inmem-0.23.2.dist-info/METADATA,sha256=Mra4MM_1TaYEatjLHb664VPCxvlQ-NjdZ-OtVe3RyDQ,570
|
|
14
|
+
langgraph_runtime_inmem-0.23.2.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
15
|
+
langgraph_runtime_inmem-0.23.2.dist-info/RECORD,,
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
langgraph_runtime_inmem/__init__.py,sha256=oKfMmvvPRewTlo9oduB3tCC3l2b2MiD_9lka4PMm_5M,337
|
|
2
|
-
langgraph_runtime_inmem/_persistence.py,sha256=exchMr_NQB_h7PHt0vq5QBh25cOGoW0jHAFo07b1BFI,1711
|
|
3
|
-
langgraph_runtime_inmem/checkpoint.py,sha256=VD5c6CktsToo_f4qPe1WP_csdonQoOb7h5lHv4U0ZAE,8372
|
|
4
|
-
langgraph_runtime_inmem/database.py,sha256=iP7W1SI4kUkqcHtkg3aMmP-YLgZfvMHANwN-P4Pb1pY,6607
|
|
5
|
-
langgraph_runtime_inmem/inmem_stream.py,sha256=PFLWbsxU8RqbT5mYJgNk6v5q6TWJRIY1hkZWhJF8nkI,9094
|
|
6
|
-
langgraph_runtime_inmem/lifespan.py,sha256=51w3ZKvxcosd7XKkTE2Tnxtr3tux4rJuChGEN0CuvCY,4935
|
|
7
|
-
langgraph_runtime_inmem/metrics.py,sha256=_YiSkLnhQvHpMktk38SZo0abyL-5GihfVAtBo0-lFIc,403
|
|
8
|
-
langgraph_runtime_inmem/ops.py,sha256=OZ1VicFoh9eOxD15LbZsmCZ1JTaWkMUjdY0nF0t9e-k,120806
|
|
9
|
-
langgraph_runtime_inmem/queue.py,sha256=WM6ZJu25QPVjFXeJYW06GALLUgRsnRrA4YdypR0oG0U,9584
|
|
10
|
-
langgraph_runtime_inmem/retry.py,sha256=XmldOP4e_H5s264CagJRVnQMDFcEJR_dldVR1Hm5XvM,763
|
|
11
|
-
langgraph_runtime_inmem/routes.py,sha256=VVNxgJ8FWI3kDBoIgQUWN1gY5ivo7L954Agxzv72TAY,1377
|
|
12
|
-
langgraph_runtime_inmem/store.py,sha256=a3YKsLnFv4bu3zPvagIFv0xmtrIp_pmGvj1CnD3PHL0,3682
|
|
13
|
-
langgraph_runtime_inmem-0.23.0.dist-info/METADATA,sha256=9x1G8RrISXklr1MikxsE4kJFZTswjmATqNgA0EsPQYY,570
|
|
14
|
-
langgraph_runtime_inmem-0.23.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
15
|
-
langgraph_runtime_inmem-0.23.0.dist-info/RECORD,,
|
|
File without changes
|