Update name to InMemorySaver (#2044)

(Keep MemorySaver around for backwards compatibility)

"MemorySaver" is ambiguous: is it saving memories? Where is it saving
memories to?

InMemorySaver aligns naming InMemoryStore as well as similar LangChain
objects (InMemoryVectorStore, etc.)
This commit is contained in:
William FH
2025-02-05 22:04:25 -08:00
committed by GitHub
parent 6a36f4bf91
commit 3daa4ae466
7 changed files with 70 additions and 55 deletions
+4 -4
View File
@@ -15,7 +15,7 @@ from langgraph.checkpoint.base import (
SerializerProtocol,
copy_checkpoint,
)
from langgraph.checkpoint.memory import MemorySaver, PersistentDict
from langgraph.checkpoint.memory import InMemorySaver, PersistentDict
class NoopSerializer(SerializerProtocol):
@@ -26,7 +26,7 @@ class NoopSerializer(SerializerProtocol):
return "type", obj
class MemorySaverAssertImmutable(MemorySaver):
class MemorySaverAssertImmutable(InMemorySaver):
storage_for_copies: defaultdict[str, dict[str, dict[str, Checkpoint]]]
def __init__(
@@ -71,7 +71,7 @@ class MemorySaverAssertImmutable(MemorySaver):
return super().put(config, checkpoint, metadata, new_versions)
class MemorySaverAssertCheckpointMetadata(MemorySaver):
class MemorySaverAssertCheckpointMetadata(InMemorySaver):
"""This custom checkpointer is for verifying that a run's configurable
fields are merged with the previous checkpoint config for each step in
the run. This is the desired behavior. Because the checkpointer's (a)put()
@@ -126,7 +126,7 @@ class MemorySaverAssertCheckpointMetadata(MemorySaver):
)
class MemorySaverNoPending(MemorySaver):
class MemorySaverNoPending(InMemorySaver):
def get_tuple(self, config: RunnableConfig) -> Optional[CheckpointTuple]:
result = super().get_tuple(config)
if result: